A Simple Stack Question (c++)

Posted: September 1, 2011 in Uncategorized

I just started to learn stacks. How can I count the number of Items in astack by using ADT stack operations?? Can u help me?


>empty auxiliary stacks are available.
Getting information out of you people is like pulling teeth. Did you know that? I’ll assume that you can only use push, pop, and empty. In that case, pop every item in the stack, increment a counter and push that item onto a secondstack. When the first stack is empty, do the reverse but don’t increment the counter and you’ll have the same stackthat you started with.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s