Hi code-ninja!
When you pass through the list you check if the current element is the one you want to remove:
and if it isn't, you move to the next element:if($temp->[VAL] == $ele) {
However the pred-Element still stays the first one ... so when you remove the 16, you would link the 25 directly after the 1. You will need to adjust pred also.$temp = $temp->[NEXT];
note: your code also needs some adjustment if you want the possibility to delete the first element.
HTH, Rata
In reply to Re: Linked List
by Ratazong
in thread Linked List
by code-ninja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |