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


Please Help Members By Posting Answers For Below Questions

What is the benefit of oop?

561


State what is encapsulation and friend function?

685


What is purpose of inheritance?

634


What is a class in oop?

589


hi all..i want to know oops concepts clearly can any1 explain??

1669






What is encapsulation oop?

564


Where You Can Use Interface in your Project

1412


What are two types of polymorphism?

600


Can destructor be overloaded?

583


What is difference between abstraction and encapsulation?

580


Why is encapsulation used?

567


What does enum stand for?

605


What is the fundamental idea of oop?

618


Templates mean

1579


What does sksksk mean in text slang?

1486