Data Structure Linked list Question:

Explain Java code for recursive solution's base case?

Tweet Share WhatsApp

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 PDF Read All 22 Linked list Questions
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?