Linked List

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 113
Reputation: abhi_elementx is an unknown quantity at this point 
Solved Threads: 6
abhi_elementx's Avatar
abhi_elementx abhi_elementx is offline Offline
Junior Poster

Re: Linked List

 
0
  #11
Jan 23rd, 2008
In order to delete the last node of the singly linked list do this;
1.Take two pointers.
2.Assign 1st pointer to the head and 2nd to the next node.
3.traverse the list till the last node such that 2nd ptr points to last node and 1st ptr oints to the previous node.
4.assign NULL to the 1st ptr .
5.Free the 2nd ptr
PEACE !
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Linked List

 
0
  #12
Jan 23rd, 2008
Originally Posted by wazzam View Post
I was reading between the lines that he was 'supposed' to extend a list because - let's face it - you'd only implement linked-lists in C++ as an exercise. Any commercial dev would use STL.
This is not true. The STL list implementation is not the only style of linked list. For starters, you can't make a new list with one extra element on the front without modifying the original or copying the whole thing. A reasonable alternative linked list implementation is a singly linked immutable list with reference-counted nodes. Or that could be implemented as a singly linked list with a custom allocator that handles garbage collection. Most of the STL containers are limited in that they're designed to be used in a single-threaded, stateful manner.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 35
Reputation: olams is an unknown quantity at this point 
Solved Threads: 0
olams olams is offline Offline
Light Poster

Re: Linked List

 
0
  #13
Jan 23rd, 2008
thank you to everyone who replied.
i figured it out. i only used one pointer.
thanks anyway
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC