linked list search question?

ok so I'm trying this thing, where I store fractions in a structure and put the structures into a linked list. THen I display them backwards. THIS WORKS PERFECTLY. BUT after displaying when I try to search a fraction on that linked list, it doesn't find it no matter what as my linked list only checks the last node.
So QUESTION: Could this be because when I display it, I change the place of the node somehow. If so how can I fix it. If not, what else could be the issue.

PS I'm doing this in assembly but C++ logic will totally work. Any suggestion??

Thanks :)

2010-12-10T11:08:21Z

OHHH never mind you guys, I just had a miscount for the stack pointer bytes. missed 2 bytes so it gave me weird addresses instead of the actual values.


Thanks you all!! :)

usman2010-12-10T08:52:48Z

Favorite Answer

you may accociate a vriable in the node structure of ur link list say count, initialize it by 0

while creating 10 nodes name each of them with the help of this variable ,i mean first node =1 , 2nd =2 and so on
so when you print the list backward check at last what is the value of count ,
this will draw important conclusions to test where your pointer is ,from here you have taken the the position of your head pointer you can easily make the logic to search through out the list while traversing it backward

Anonymous2010-12-10T09:08:57Z

comment the part with which you are displaying the link list and then try if the you are able to search a fraction. I think you are making certain changes to the pointers while displaying the linked list.

Anonymous2010-12-10T08:56:42Z

Singly linked or doubly linked? Are you traversing it from the front or from the end? (No, displaying it should NEVER change the pointers. If it is your code is bad.)