15-11-2012, 03:57 PM
ARRAY IMPLEMENTATION OF STACK
ARRAY IMPLEMENTATION OF STACK.docx (Size: 14.88 KB / Downloads: 21)
To write a C-program to implement stack using array data structure.
And perform the following stack operations
1. POP
2. PUSH
3. PEEP
Algorithm
STEP 1:Start
STEP 2:Initialize stack, will=1,i, num
STEP 3:Add element in stack
PUSH(S,TOP,X)
3.a. [Check overflow condition]
If(TOP>=N) then
Write(“Stack is full”)
3.b. [Insert element]
[Increment TOP]
TOP <- TOP+1
S[TOP]<- X
3.c. [Finish the process]
STEP 4: Delete element in stack
POP(S,TOP)
4.a. [Check for underflow condition]
If(TOP <- 0) then