affiliate marketing
Showing posts with label ARRAY IMPLEMENTATION OF STACK coding. Show all posts
Showing posts with label ARRAY IMPLEMENTATION OF STACK coding. Show all posts

Monday, 12 December 2011

ARRAY IMPLEMENTATION OF STACK


ARRAY IMPLEMENTATION OF STACK
Aim
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
                                                Write(“Stack is empty”)
                                                4.b. [Delete element]
                                      [Decrement TOP]
                                      TOP<- TOP-1
                                      Delete S[TOP+1]
                                       4.c.[Finish the process]
STEP 5:Stop
Coding: