Data Structure Linked list Question:
Download Job Interview Questions and Answers PDF
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
}
Download Linked list Interview Questions And Answers
PDF
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? |