![]() |
a stack question
we had this problem given to us, and i would just like a confirmation as to who is correct on the answer
the stacks S and T are initially empty and we need to say what they would "look like" after these operations S.push(1) S.push(2) T.push(3) T.push(4) S.pop T.GetStackTop(StackTop) S.push(StackTop) S.push(5) T.pop(StackTop) T.push(6) I came up with S containing (from bottom to top) 1,4,5 and T containing 3,6 but a friend had only 6 left in T could someone please specify which is the right solution? |
You'll have to explain what GetStackTop does in terms of its effect on the contents. If it merely returns the value, without removing it (which seems likely), then just make a table. The operation, T.pop(StackTop), seems ridiculous. How can you specify some parameter to pop? One pops the top. If it's specifiying a destination in which to place the popped value, it's useless, as you don't subsequently use it.
In other words, a question without the necessary supportive information isn't likely to result in a good answer, except by accident. |
Agree with DaWei on this. Provide more information and then you'll get something good! I do not know what StackTop is.
|
Are we really talking about stacks here???
|
| All times are GMT -5. The time now is 2:47 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC