0
29kviews
Write algorithm to insert a new node in linked list at the beginning, and at the end.

PROCEDURE (insert-node-as-a-first-node) ( list, link, info,new, item)

//List = given single link list //Link = link part of the node //info = information part of the node //new = newly created node //item = item to be inserted at first position of a linked list

Step 1[checking for overflow] If (new==NULL) a. print overflow b. Goto step 4 [End of if statement]

Step 2 new -> info =item New->link = NULL Step 3 New->link=start Start= new Step 4 Exit


1 Answer
1
2.6kviews
// algorithm to insert new node at the beginning
Step 1: IF AVAIL = NULL
Write OVERFLOW
Go to Step 7
[END OF IF]
Step 2: SET NEW_NODE = AVAIL
Step 3: SET AVAIL = AVAIL NEXT
Step 4: SET DATA = VAL
Step 5: SET NEW_NODE NEXT = START …

Create a free account to keep reading this post.

and 3 others joined a min ago.

Please log in to add an answer.