Push Operation On Stack
Tags : Push Operation , Data Structure Push Operation : Before Starting with Push Operation , Let us First make it clear , "How Stack Push Operation Works ?"
Push Operation :
- Push Refers as "Adding Elements onto Stack".
- Push Operation carried out in following 2 steps -
- First Increment Variable "top" so that it now refers to next memory location.
- Secondly Add Element Onto Stack by accessing array.
- Main Function Should ensure that stack is not full before making call to push() in order to prevent "Stack Overflow"
What is Stack Overflow ?void push(stack *s,int num) { s->top = s->top + 1; s->data[s->top] = num; }
- Pushing element onto stack which is already filled is refer as "Stack Overflow".
- Using array representation of stack ,variable "MAX" is used to keep track of "Number of Maximum Elements"
int full(stack *s) { if(s->top == MAX-1) //Stack is Full return(1); else return(0); }
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