-
using the operation pop and push set i to the second element from the top of the stack, leaving the stack to without its top two element0
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a
member of our community. Consider creating an
account or login.
Replies
-
Member • Nov 24, 2012
First of all Welcome to CE.
I am not sure what your question really is. Is it that you want to know how to initialize a stack with no elements or that you want to know how to use push and pop instructions.
For the first scenario(Initializing the stack), keep one variable named TOP which will signify the number of elements in the stack and according to the working of the stack, the programmer will have access to the element which corresponds with the TOP.
I interpret this as you want to push i to the second positionsridhar tusing the operation pop and push set i to the second element from the top of the stack, leaving the stack to without its top two element
a)with the top element.
for a), you need to pop the top element, and store it in some variable , then push i and then push the element in variable back to the stack.
If this answer doesn't help you then let us know what is your question with more clarity
for that you can even use diagrams and upload them.Are you sure? This action cannot be undone. -
Member • Nov 26, 2012
I think I get your Error you forgot to decrement i when you poped your stack and so top is not showing the value you are pushing in later.
I am not a DS guy if this is your prob do post here and #-Link-Snipped-# will guide you furthurAre you sure? This action cannot be undone. -
Member • Nov 26, 2012
if they given a post-fix expression how to write code for the implementing the post-fix expression to infix expressionAre you sure? This action cannot be undone. -
Member • Nov 26, 2012
There is some problem here buddy Can you pls post what exactly is your problem we are a bit unclear here right nowsridhar tif they given a post-fix expression how to write code for the implementing the post-fix expression to infix expression
Sorry about that but more info from you can help us tackle this easier for youAre you sure? This action cannot be undone.