Double Linked List handling problems

Hi, Ive done program that reads in coordinates from text file and stores them in double linked list. After coordinates are read in algorithm calculates its importance. User selects number of coordinates he wants to remove. Then program finds double linked list element with lowest importance value and removes it from list. Problem I have is that when search is done and node is find, when trying to remove it, it cant find it. Could you please advice me or point out what i did wrong.


Any advice or help would be appreciated
Last edited on
1
2
3
4
5
6
7
8
9
for (current = current->next; current != NULL; current = current->next)
		{
			if (current->F < f)
			{
				f = current->F;
// save the node here as well instead of searching for f again afterwards
        lowest = current;
			}
		}


Then you could remove this line:
lowest = search(f);


Compare this if condition with the condition of your loop
if (p->next != NULL && (p->next->x == x && p->next->y == y && p->next->F == F))

Hint: your loop terminates before u reach the node you want to delete

Have fun
Last edited on
Thank you very much, Im gonna try that now
it worked flawlessly after changing loop. Thank you very much Glandy
Topic archived. No new replies allowed.