Log in
updated 11:29 AM UTC, May 4, 2016

Delete an Item in a Singly linked List

You will be given a reference/pointer to an item in a singly linked list and not its predeccessor, you have to delete that.
This seems tricky if you just concentrate on the item pointer. you have to think in a different way.


Concentrate on the content than just on pointer.
Copy the contents of the item.next to item and delete the item.next.

Piece of code (Java based/ try yourself adding it in C)
Item.content = item.next.content;
deleteItem = item.next;
item.next = item.next.next;

Powered by Bullraider.com
Follow Us on Twitter
Find Us on Facebook
Follow Us on Google
Follow Us on Pinterest