This algorithm deletes from a linked list the first node N which contains given ITEM of information.
1. [Use procedure FINDB to find the location of N and its preceding node.]
2. If LOC = NULL, then : write : ITEM not in list, and Exit.
3. [Delete node.]
If LOCP = NULL, then:
Set START : = LINK[START]. [Delete first node]
Else :
Set LINK[LOCP] : = LINK[LOC]
[End of structure]
4. [Return deleted node to the AVAIL list.]
Set LINK[LOC] : = AVAIL and AVAIL : = LOC.
5. Exit.
0 comments:
Post a Comment