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 are benefits of oop?
What is encapsulation in oops?
What is polymorphism and its types?
Write a program to sort the number with different sorts in one program ??
Can enum be null?
How is class defined?
Is abstract thinking intelligence?
Is data hiding and abstraction same?
What makes a language oop?
What is the example of polymorphism?
What does and I oop mean in text?
Why do we use oops?
What is object in oop?
What is difference between polymorphism and inheritance?
What is debug class?what is trace class? What differences are between them? With examples.