Home About Contact Privacy Terms Disclaimer
TECHAntena
Last Updated On: July 10, 2016
Editor: Adeeb C

C++ Program to Implement Stack Operations Using Linked List (Algorithm)

Category: C++,Programing
Tags

AIM:

Write a C++ program to implement stack operations using linked list.

ALGORITHM:

PROCEDURE CREATE_STACK(TOP)
[Where ‘head’ pointer has been caught in pointer ‘TOP’ and link of head has done NULL]

1. [Allocating memory for new node & having the value from user]

Call GETNODE (TOP)
DATA (TOP) <– ‘xyz’
LINK (TOP) <– S.
S <– TOP.

2. [Checking the value & calling the function recursiverly]

if(DATA (TOP) <= 0)
return (LINK(TOP))
else
Call CREATE_STACK (TOP)

3. [FINISH]
return.