Page 6 - Fundamentals of Stack in Data Structure
P. 6

}


               else



               {


               cout << "Stack is not empty";


               }



               }



               Position of Top                               Status of Stack



               -1                                            Stack is Empty



               0                                             Only one element in Stack



               N-1                                           Stack is Full



               N                                             Overflow state of Stack



               Analysis of Stacks



               Below   mentioned   are   the   time   complexities   for   various
               operations that can be performed on the Stack data structure.



                    Push Operation : O(1)
                    Pop Operation : O(1)

                    Top Operation : O(1)

                    Search Operation : O(n)
   1   2   3   4   5   6   7   8   9   10   11