comp.lang.ada
 help / color / mirror / Atom feed
From: byrner <byrner@db.erau.edu>
Subject: How: Remove end of Linked List w/ tail pointer?
Date: 1997/11/30
Date: 1997-11-30T00:00:00+00:00	[thread overview]
Message-ID: <65s8gp$pdc@bgtnsc03.worldnet.att.net> (raw)


Does anybody know of a way to make the TAIL pointer point to the previous node in the linked list 
structure defined below without starting at the HEAD and performing a loop to search through the entire list?  
Essentially, what I need to do is remove the last node from the list, but before I do this, I will have to 
update the TAIL pointer so it points to the node which will be the tail of the list after I remove the last 
node (the next to last node)  Is this even possible without searching the entire list?  I am using Ada95.


type LISTNODE;
type LIST is access LISTNODE;
type LISTNODE is record
  TIME: NATURAL;
  NEXT: LIST;
end record;

type LISTPOINTER is record
  DATA: NATURAL;
  HEAD: LIST;
  TAIL: LIST;
  SIZE: NATURAL; --number of nodes in linked list
end record;

NOTE: I am not actually going to delete the last node; I want to move it from the end of one linked list to the 
end of a second one.  I plan to make the second list point to the end of the first list, and then remove the 
link from the first list to that last node.  I do not want to search through the whole list because this 
operation will be performed with up to 8 lists until they are all as close as possible to being the same 
length.  The entire procedure above will then be repeated up to 6000 times, so it would take a while to search 
through the list to find the next to last node in the list each time.

     Any ideas of how this can be done?  Any help would be greatly appreciated!  Thank you.


byrner@db.erau.edu




             reply	other threads:[~1997-11-30  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-30  0:00 byrner [this message]
1997-11-30  0:00 ` How: Remove end of Linked List w/ tail pointer? Fergus Henderson
1997-11-30  0:00 ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox