Deleting Pointed node in Singly Linked List

Reply

Join Date: Feb 2006
Posts: 2
Reputation: vissure is an unknown quantity at this point 
Solved Threads: 0
vissure vissure is offline Offline
Newbie Poster

Deleting Pointed node in Singly Linked List

 
0
  #1
Feb 9th, 2006
How to delete a node in a Singly Linked List using a pointer that points to the node? (Assume that you cannot traverse the list to find the previous node)

--
With Regards
Vishnu
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,579
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 709
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Deleting Pointed node in Singly Linked List

 
0
  #2
Feb 9th, 2006
This is a common test question. Have you tried to solve it yourself? Here's a hint: you can move data as well as change links.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2
Reputation: vissure is an unknown quantity at this point 
Solved Threads: 0
vissure vissure is offline Offline
Newbie Poster

Re: Deleting Pointed node in Singly Linked List

 
0
  #3
Feb 9th, 2006
Ya, I know u can shift up the links following the one pointed to. Or u can swap with the last node and delete the last node(If sorted order is not a criteria). But this is an optimisation problem. Consider this as an infinitely long link list. Both the above methods are not practical in such a scenario as both are computational intensive.
Is there any other way??
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,039
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Deleting Pointed node in Singly Linked List

 
0
  #4
Feb 10th, 2006
You only need to copy one data element and change one link.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 244
Reputation: Drowzee is an unknown quantity at this point 
Solved Threads: 5
Drowzee Drowzee is offline Offline
Posting Whiz in Training

Re: Deleting Pointed node in Singly Linked List

 
0
  #5
Feb 10th, 2006
[Edit: Post removed due to misinterpretation of the question. Assumed pre-check was possible]
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,579
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 709
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Deleting Pointed node in Singly Linked List

 
0
  #6
Feb 10th, 2006
>Ya, I know u can shift up the links following the one pointed to.
Shift? It sounds like you're confused, but we'll proceed.

>Or u can swap with the last node and delete the last node(If
>sorted order is not a criteria).
Sorted order is irrelevant since you're unlinking the node causing disorder anyway. And you don't need to swap unless you're returning the deleted node and need the data in the calling function.

>Both the above methods are not practical in such a scenario
>as both are computational intensive.
Constant time performance with two operations is computationally intensive? The only way to improve that performance is to drop down to inline assembly and optimize the data movement with low level register tricks. Even then you won't see much of an improvement.

You say you understand the solution I was suggesting, but you obviously don't if you think it's "computationally intensive".
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Deleting Pointed node in Singly Linked List

 
0
  #7
Feb 10th, 2006
Narue...your replyies seems to me like you are a very aggressive person.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 269
Reputation: Clinton Portis is an unknown quantity at this point 
Solved Threads: 25
Clinton Portis's Avatar
Clinton Portis Clinton Portis is offline Offline
Posting Whiz in Training

Re: Deleting Pointed node in Singly Linked List

 
0
  #8
Feb 10th, 2006
i like agressive

RrrRRraawwrrrrr.....
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Deleting Pointed node in Singly Linked List

 
0
  #9
Feb 11th, 2006
Narue is not so much agressive as frustrated with the lack of effort by many (especially younger) people in this world to even attempt to solve their own problems, an attitude I can very much relate to.

But then we're both professionally employed in this profession and have to work with the end result of an educational cycle in which such lack of effort gets people degrees and diplomas which in turn get them hired to be our colleagues, saddling us with the burden of doing their work to get projects completed.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Deleting Pointed node in Singly Linked List

 
0
  #10
Feb 11th, 2006
Originally Posted by jwenting
Narue is not so much agressive as frustrated with the lack of effort by many (especially younger) people in this world to even attempt to solve their own problems, an attitude I can very much relate to.

But then we're both professionally employed in this profession and have to work with the end result of an educational cycle in which such lack of effort gets people degrees and diplomas which in turn get them hired to be our colleagues, saddling us with the burden of doing their work to get projects completed.
In my school, we have an IT technician, we call him Mr. Grumpy because everytime we ask him to fix this or do that he is always grumpy, probably due to the reasons outlined above.

Whilst it is entirely possible that these people can lead socially rewarding lives outside of work I find it difficult to imagine. A happy IT associated person, - are you kidding me? The constraints of life make this unlikely. :lol:
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the C Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC