Data Structures : Stack

theStack.push( 1);
theStack.push(2);
theStack.push(3);
theStack.push(theStack.popO);
theStack.push(theStack.popO +theStack:popO);
theStack.push(6);
theStack.push(7);
theStack.push(theStack.popO * theStack.popO);

Hi I am having problem in understanding above mentioned lines. could anyone please explain above line. First 3 lines adding values to the stack frames. what happens with 4th-8th lines?
theStack.popO should probably be theStack.pop().

push adds an element at the top of the stack.
pop removes an element from the top of the stack.

Line 4 pops the value 3 off the stack and then pushes the same value 3 on to the stack again leaving the stack in the same state as before.
Last edited on
Topic archived. No new replies allowed.