This is a stack actually. Similar situation. I assume that Push pushes the first argument onto the stack. Pop pops the stack, and GetStackTop gets the top element of the stack back in the first argument (StackTop in this case) without changing the stack.

Q:

T:

Q.Push(1,success);

Q.Push(2,success);

Q: 1, 2

T:

T.Push(3,success);

T.Push(4,success);

Q: 1, 2

T: 3, 4

Q.GetStackTop(StackTop,success);

Q: 1, 2

T: 3, 4

and StackTop is 2

T.Push(StackTop,success);

Q: 1, 2

T: 3, 4, 2

Q.Pop(success);

Q: 1

T: 3, 4, 2

T.Push(5,success);

Q.Push(6,success);

Q: 1, 6

T: 3, 4, 2, 5

So yes, in fact stacks are very similar to queues. They are normally thought of oriented vertically rather than horizontally, but that is harder to type. The main difference is that a Pop takes off the last element added, whereas a Delete (for a queue) takes of the first element that was added. A queue is a FIFO queue (first in, first out), whereas a stack is a LIFO (last in, first out) queue.

Looks like we got the same answer (your stack top was on the "other" side), except for the Pop.

What do you think?

Q:

T:

Q.Push(1,success);

Q.Push(2,success);

Q: 1, 2

T:

T.Push(3,success);

T.Push(4,success);

Q: 1, 2

T: 3, 4

Q.GetStackTop(StackTop,suc

Q: 1, 2

T: 3, 4

and StackTop is 2

T.Push(StackTop,success);

Q: 1, 2

T: 3, 4, 2

Q.Pop(success);

Q: 1

T: 3, 4, 2

T.Push(5,success);

Q.Push(6,success);

Q: 1, 6

T: 3, 4, 2, 5

So yes, in fact stacks are very similar to queues. They are normally thought of oriented vertically rather than horizontally, but that is harder to type. The main difference is that a Pop takes off the last element added, whereas a Delete (for a queue) takes of the first element that was added. A queue is a FIFO queue (first in, first out), whereas a stack is a LIFO (last in, first out) queue.

Looks like we got the same answer (your stack top was on the "other" side), except for the Pop.

What do you think?