C++ program using linked list operations
To write a program to implement linear linked list operations.
Insert ( );
INFIRST (INFO, LINK, START, AVAIL, ITEM)
This algorithm inserts ITEM as the first node in the list.
1. [OVERFLOW?] If AVAIL = NULL, then : Write : OVERFLOW, and Exit.
2. [Remove first node from AVAIL list. ]
Set NEW : = AVAIL and AVAIL : = LINK [AVAIL].
3. Set INFO[NEW] : = ITEM. [Copies new data into new node. ]
4. Set LINK[NEW] : = START. [New node now points to original first node. ]
5. Set START : = NEW. [Changes START so it points to the new node. ]
Delete ( );
DEL ( INFO, LINK, START, AVAIL, LOC, LOCP)
This algorithm deletes the node N with location LOC, LOCP is the location of the node which precedes N or, when N is the first node, LOCP = NULL.
1. If LOCP = NULL, then:
Set START : = LINK [START]. [Deletes first node.]
Set LINK [LOCP] : = LINK[LOC]. [Deletes node N.]
[End of If structure.]
2. [Return deleted node to the AVAIL list.]
Set LINK[LOC] : = AVAIL and AVAIL : = LOC.