Insert As First Node in A Linked - List

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

www.eazynotes.com Gursharan Singh Tatla Page No.

INSERT AS FIRST NODE IN A LINKED LIST

Insert First ( ):
Description: Here START is a pointer variable which contains the address of first node. ITEM is the value
to be inserted.

1. If (START == NULL) Then


2. START = New Node [Create a new node]
3. START->INFO = ITEM [Assign ITEM to INFO field]
4. START->LINK = NULL [Assign NULL to LINK field]
5. Else
6. Set PTR = START [Initialize PTR with START]
7. START = New Node [Create a new node]
8. START->INFO = ITEM [Assign ITEM to INFO field]
9. START->LINK = PTR [Assign PTR to LINK field]
[End of If]
10. Exit

You might also like