Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 3rd, 2007, 9:56 PM   #1
JJH35
Newbie
 
Join Date: Nov 2006
Posts: 6
Rep Power: 0 JJH35 is on a distinguished road
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?
JJH35 is offline   Reply With Quote
Old Jun 4th, 2007, 12:13 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 4th, 2007, 1:03 AM   #3
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Agree with DaWei on this. Provide more information and then you'll get something good! I do not know what StackTop is.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Jun 4th, 2007, 7:08 AM   #4
pegasus001
Hobbyist Programmer
 
pegasus001's Avatar
 
Join Date: Nov 2006
Location: 163H
Posts: 215
Rep Power: 3 pegasus001 is on a distinguished road
Are we really talking about stacks here???
__________________
You never test the depth of a river with both feet.
The believer is happy. The doubter is wise.
Free speech carries with it some freedom to listen.
The next generation will always surpass the previous one. It`s one of the never ending cycles of life.
pegasus001 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining languages titaniumdecoy Other Programming Languages 12 Jul 13th, 2006 3:03 PM
stack question bl00dninja C++ 9 May 8th, 2006 8:54 PM
Assembly tutorial, part one. Mad_guy Software Design and Algorithms 21 Apr 15th, 2006 8:02 PM
When to use the new keyword in C++? titaniumdecoy C++ 28 Mar 16th, 2006 1:36 PM
A noob to Assembly CodeJunkie Assembly 12 Jan 25th, 2006 3:06 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC