deleting from end of linked list 
Author Message
 deleting from end of linked list

Can anyone give me an example of how to delete the last node of a
linked list?
I understand that usually to delete This for example one would go by
prev^.link := this^.link and then dispose(this), but if This is the
last node, how can it go to this^.link when that is nil?

Thanks in adv.
D.

Sent via Deja.com
http://www.*-*-*.com/



Sat, 28 Jun 2003 18:11:13 GMT  
 deleting from end of linked list

Quote:
> I understand that usually to delete This for example one would go by
> prev^.link := this^.link and then dispose(this), but if This is the
> last node, how can it go to this^.link when that is nil?

I assume [not all was clear]:
 (prev points to previous node in list)
 link points to next node in list [I usually use next, so that's why]
Then it's enough to set this^.prev^.link to nil (that equals saying the
'new' last node has no successor in the list (while it used to have 'this'
as successor)) and disposing 'this'. And this^.link is nil, so that's the
same. Note that you can assign something:=something_that_has_value_nil, but
not say something_that_has_value_nil^.some_name.

KuifWare
http://kuifware.freeservers.com



Sun, 29 Jun 2003 04:00:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. delete from end of linked list

2. Delete a node from middle of a linked list

3. Help Link List, Reverse Print List Node

4. Link List , use recursive routine to reverse print the node of the list

5. Doubly Linked List problem

6. Linked Lists

7. Sorting a linked list by multiple criteria

8. Linked Lists and Pointers

9. Linked List

10. Writting and Reading a linked list from/to a file

11. Record Link List Help please

12. Linked Lists Beyond the 640kb Limit

 

 
Powered by phpBB® Forum Software