User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 392,372 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,737 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:

add function of a liked list class

Join Date: Jul 2005
Posts: 1,095
Reputation: Lerner is a jewel in the rough Lerner is a jewel in the rough Lerner is a jewel in the rough Lerner is a jewel in the rough 
Rep Power: 9
Solved Threads: 141
Lerner Lerner is offline Offline
Veteran Poster

Re: add function of a liked list class

  #2  
Oct 31st, 2006
1) What's the terminating condition of the for loop?

2) If I have APA and I want to remove the first A then I can store the head in a temp node, change head to to head->next, then delete the temp node.

However, if I have APCP and I want to remove the first P toget ACP I have to disconnect the first P from C and connect the A to the C without changing head and then I can delete P. In theory, if I use a searching node called current, then if current->next->value == P, then current->next can be assigned to a temp node, current->next->next can be assigned to current->next , temp node->next can be nulled and then temp node can be deleted. With any luck it might work. Alternatively, I could keep track of current node and prior node where current node is same as prior node next, as long as the list is longer than a single node. Then current node->next can be assigned to prior node->next and current node can be deleted. That should work, too. Good luck.
Reply With Quote  
All times are GMT -4. The time now is 1:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC