Follow

Translate

Sunday, March 20, 2016

Inserting at the Beginning of a List


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
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment