Data Structure Linked list Question:

Download Job Interview Questions and Answers PDF

Explain Java code for recursive solution's base case?

Linked list Interview Question
Linked list Interview Question

Answer:

/* if we are at the TAIL node:
*/
if(currentNode.next == NULL)
{
//set HEAD to TAIL since we are reversing list
head = currentNode;
return; //since this is the base case
}

Download Linked list Interview Questions And Answers PDF

Previous QuestionNext Question
Tell me what should be done in the base case for this recursive problem?Explain reverse a linked list recursive Java solution?