Algorithms which delete nodes from linked lists come up in various situations. We discuss two of them here. The first one deletes the node following a given node, and the second one deletes the node with a given ITEM of information. All our algorithms assume that the linked list is in memory in the form LIST(INFO, LINK, START, AVAIL).
All of our deletion algorithms will return the memory space of the deleted node N to the beginning of the AVAIL list. Accordingly, all of our algorithms will include the following pair of assignments, where LOC is the location of the deleted node N:
LINK[LOC] : = AVAIL and then AVAIL : = LOC
Some of the algorithms may want to delete either the first node or the last node from the list. An algorithms that does so must check to see if there is a node in the list, If not, i.e, If START = NULL, then the algorithms will print the message UNDERFLOW.
0 comments:
Post a Comment