Quick Quiz on Recursion with Data Structures!
This lesson will test your knowledge on how to solve linked list, trees ,and graph problems using recursion.
Solve this Quiz!
1
Assume that you have a linked list with five nodes. The task is to traverse the linked list recursively.
void printListRecursively(Node* head)
{
//base case
//recursive case
cout << head->data <<endl;
printListRecursively(head->next);
}
What would be 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.