Algorithm: INSFIRST(INFO, LINK, START, AVAIL, ITEM)
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]
6. Exit
0 comments:
Post a Comment