Array Representation of Stack in C Programming :
We have already discussed "what actually stack is ?". Stack is used as Linear data structure which cane be accessed from only one end . Stack can be represented as "Array" . For Representing Stack we have to declare the following data structure -
typedef struct stack { int data[MAX]; int top; }stack;
- 1-D array is used to hold the element of the stack.
- Variable "top" keeps track of "Topmost" Element in the stack.
- "MAX" is used as Constant which gives maximum size of Stack.
Initial Set Up :
- "Top" is set to -1. [-1 indicated Empty Stack].
- MAX - Any number .
- When value of top becomes "MAX-1" after a series of insertion then Stack is said to be full.
- After Push Operation : top = top + 1
- After Pop Operation : top = top - 1
- When top = -1 then Stack is said to be empty.
0 Comments:
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email