Quote:
Originally Posted by shabbir
Thats a general concept of deleting a node and NULL means last node if your one is cyclic you can check the value of the next pointer to be equal to the header and that means you have travelled the complete list to find the data.

Yes free is actually similar to delete in C++. and we can delete any node using newnode -> next -> next because in the structure next means the address to the next node and we can delete the next to next node.

I hope this clears your queries to some extent.

Regarding your code you mentioned
Code:
for (int j = 1; j < length; j++) // this loop is to determine that if the first node gets deleted - then linker will point to the last node
 {
 linker = linker -> shortlink;
 }
But I dont see any thing related to deleting but it just loops through all the element and breaks assigning wrong value to your variable linker.

for (int j = 1; j < length; j++) // this loop is to determine that if the first node gets deleted - then linker will point to the last node
{
linker = linker -> shortlink;


That piece of code is correct. What's thats doing is, it's getting the node before the node deleted and making it point to the node after the deleted node. So if i delete node 1, then node 8 will point to 2 and not 1.
Ah!!! I notice my problem now - i'm not decreasing the length variable when a node is getting deleted - stupid me!!

OH ITS WORKING LIKE A DREAM - Mate, you got no idea how much i appreciate your help!!! I've been tossing all over the house for 2 days tryin to figure this crap out!!!

Last edited by coolio2006; 26Aug2006 at 15:56..