Blogger

Delete comment from: Javarevisited

Anonymous said...

I was asked this ques on linked list..
Remove the current node from the list. Lets say there is a linked list as below
A1->A2->A3->A4->A5
the pointer is at A3. You have to delete the node A3 and you dont have the pointer to A2.

I still havent got the solution for that.
Little help here.. anyone ???

Answer :-
1) store value of A3 in some variable (temp).
2) copy the value of A4 to A3.
3) Delete the node A4 (can do that as we can refer to A4 and A5)
4) return temp

May 19, 2014, 9:49:27 AM


Posted to How to find If Linked List Contains Loop or Cycle in Java? Example Solution

Google apps
Main menu