Board index » delphi » Delete a node from middle of a linked list
shailku...@aol.com (SHAILKUMAR)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
shailku...@aol.com (SHAILKUMAR)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Delete a node from middle of a linked list
Hi Everyone,
How do I delete a node from the middle of a linked list. The linked list is Thank you, for your attention. shailku...@aol.com - Shail |
R.E.Dona
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Delete a node from middle of a linked listQuoteshailku...@aol.com (SHAILKUMAR) wrote: pencil and paper, draw a few pictures or diagrams, use the pencil as a pointer and walk yourself through the process. Remember that the consciousness of your program is limited to the information contained at the tip of your pencil. ;-) A double linked list is easiest since the node itself contains A single linked list is a little harder. Here you must walk a If you design your single linked list so that the link is the ...red |
Martin Fitzpatri
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Delete a node from middle of a linked listIn article <19981212022627.23197.00001...@ng-fb1.aol.com>, shailku...@aol.com says... Quote> Hi Everyone, :o).... well... here goes... each element in the linked list should have two parts: data - the data you're storing ..so in order to delete an item, you scan through until you find the item then, to remove the item from the list, change the 'link' pointer in the an eg. will probably help more here.. item 1 2 3 4 5 6 7 data x c b n m l p (the -1 indicates the end of the list, 'start' points to 2)... so, the above list is arrange into alphabetical order (b,c,l,m,n,p,x) item 1 2 3 4 5 6 7 data x c b n m l p ..and so, n is removed from the list.... if you want to release the space hope this is of some help, martin fitzpatrick -- Dos Game Development Site |
Martin Be
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Delete a node from middle of a linked listSHAILKUMAR schrieb: Quote
if you have just pointers to the next you have to search the element in front of the element you want to delete and set it NEXT-pointer to the element coming after the one you delete. when you use a double-linked list, If need the memory later in your program, hth, -- Dupe that floppy -- Spread the wealth and copy (Joe Koss) |
Rich Pasc
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Delete a node from middle of a linked listQuoteSHAILKUMAR wrote: pointer to the node "before" (pointing to) it. So, when you start, q^.next = p, and p^.next is either nil (i.e. q^ was the last node in the list) or points to the next node in the list. Then: Of course, if you had other pointers to the deleted node elsewhere in - Rich |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Delete a node from middle of a linked listIn article <36764a99.4314...@nntp.ftc-i.net>, Quote<Higgi...@ftc-i.SpAmZaP.net> wrote: Procedure Delete(p:pnode); This, however, does not work for the last node as nxt would be nil. Of course if one needs to do such deleting then maybe some other Osmo |
1. deleting node from linked list
2. Help Link List, Reverse Print List Node
3. Link List , use recursive routine to reverse print the node of the list
5. delete from end of linked list
6. deleting from end of linked list
7. Deleting From Middle Of StringGrid?
8. Deleting nodes from binary trees
9. Help:Delete a node from TTreeView.
10. Need a procedure for deleting a node from a binary search tree