Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

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 :)

Update:

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!! :)

3 Answers

Relevance
  • 1 decade ago
    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

  • Anonymous
    1 decade ago

    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.

  • Anonymous
    1 decade ago

    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.)

Still have questions? Get your answers by asking now.