algo_030
Problem Statement
Problem Statement
Write an algorithm to push to stack (Linked representation of stack)
Algorithm
Procedure push(stack, val)
begin
ptr ← getNode();
if (ptr = NULL) then
write("Stack Overflow / Memory Allocation Failed");
return(stack);
endif
INFO(ptr) ← val;
next(ptr) ← stack;
stack ← ptr;
return(stack);
end procedure1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13