What do you mean by stack program?
Get me an example stack program?
Answer Posted / harshita gangwar
<STACK>
stack is a linear kind of data structure .it works on "LIFO"
,LIFO stands for last in first out. in stack we perform two
operations i.e. insertion & deletion & these operations
performs only at one end i.e called "TOP".
for eg: a stack of books..etc
there are two operations performs-
(1) push (2) pop
there are also two conditions occures in case of stack i.e.
i.e. (i)underflow (ii)overflow
/*ALGO FOR PUSH OPERATION*/
PUSH( stack[],TOP,item, len)
1) set TOP=-1
2) if TOP==len-1, then
print stack is overflow.
3) else
set TOP=TOP+1
set stack[TOP]=item
4) EXIT.
In the PUSH operation the overflow condition generates.
/*ALGO FOR POP OPERATION*/
POP(stack[],TOP,item,len)
1) set TOP=len-1
2) if TOP==-1, then
print stack is underflow.
3) else
set item=stack[TOP]
set TOP=TOP-1
4) EXIT.
In the POP operation the underflow condition generates.
OTHER EGS OF STACK:-
(I)a stack of disks.
(II)a common model of a stack is plates in a party
where fresh plates are "PUSHED"(inserting) on to the TOP &
"POPED"(deleting) from the TOP.
| Is This Answer Correct ? | 11 Yes | 0 No |
Post New Answer View All Answers
What is class encapsulation?
Can destructor be overloaded?
What is the main feature of oop?
What is oops concept with example?
What is cohesion in oop?
What is polymorphism explain its types?
is there any choice in opting subjects like 4 out of 7
What is a class and object?
What is purpose of inheritance?
What is an advantage of polymorphism?
What is polymorphism and why is it important?
What is this pointer in oop?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
What are the benefits of polymorphism?
What is balance factor?