Right Click to Search

Friday, June 11, 2024

Array Representation of Stack | Data Structure





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. 1-D array is used to hold the element of the stack.
  2. Variable "top" keeps track of "Topmost" Element in the stack.
  3. "MAX" is used as Constant which gives maximum size of Stack.

Initial Set Up :
  1. "Top" is set to -1. [-1 indicated Empty Stack].
  2. MAX - Any number .
  3. When value of top becomes "MAX-1" after a series of insertion then Stack is said to be full.
  4. After Push Operation : top = top + 1
  5. After Pop Operation : top = top - 1
  6. When top = -1  then Stack is said to be empty.

Tags / Keywords : | , ,

Stumble
Delicious
Technorati
Twitter
Facebook

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

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates