Quick Quiz on Recursion with Data Structures!
This lesson will test your knowledge on how to solve the linked list, tree, and graph problems using recursion.
Solve this Quiz!
1
Imagine you have a linked list with five nodes. Your task is to traverse the linked list recursively.
public static void printListRecursively (Node head)
{
//base case
//recursive case
System.out.print(head.data + " ");
printListRecursively(head.next);
}
What is the base case of the above code?
A)
if (head == null)
{
return;
}
B)
if (head.next == null)
{
return;
}
Question 1 of 30 attempted
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.