Write pseudo code for push in a stack?

Answer Posted / surya8273@gmail.com

push means inserting an element on to the top of the stack.
lets define array of size 10,
int a[10]
Top<== -1 // stack is empty now.
Push(x)// x is a element to be push.lets take x=4
{
top<== top+1
// top will initialize to 1,now the top will be address to the 0 th index of array.//
a[Top]<== x
// insert x in to the 0th index of array(a[0]<== 4)//
}

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to hide the base class functionality in Inheritance?

836


What is overloading in oop?

755


What is the importance of oop?

826


What is a null tree?

846


How can you overcome the diamond problem in inheritance?

952


Why is static class not inherited?

813


Why do pointers exist?

867


What does and I oop mean in text?

842


What are the components of marker interface?

794


What is the advantage of oop over procedural language?

835


What is a class oop?

752


write a program to find 2^n+1 ?

1767


Why multiple inheritance is not possible?

782


What is cohesion in oop?

832


What is abstraction with example?

818