algo_01
Problem Statement
Problem Statement
Write an algorithm to insert a node at the beginning.
Algorithm
procedure insert_begin(head)
begin
ptr ← get_node();
print("Enter the value");
read(val);
info(ptr) ← val;
next(ptr) ← NULL;
if(head = NULL)
head ← ptr;
else
next(ptr) ← head;
head ← ptr;
endif
return(head);
end procedure1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15