Data Structure Linked list Question:
Explain Java code for recursive solution's base case?
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
}
*/
if(currentNode.next == NULL)
{
//set HEAD to TAIL since we are reversing list
head = currentNode;
return; //since this is the base case
}
Previous Question | Next Question |
Tell me what should be done in the base case for this recursive problem? | Explain reverse a linked list recursive Java solution? |