473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

implement a stack using two queues

Can any body tell me

How to implement a stack using two queues

Thax in advance

Aug 1 '07 #1
5 10744
On Jul 31, 10:22 pm, ravi <dceravigu...@gmail.comwrote:
Can any body tell me

How to implement a stack using two queues

Thax in advance
Don't you mean implement a queue using 2 stacks, which is a standard
homework problem?

Aug 1 '07 #2
On Aug 1, 7:31 am, Gene <gene.ress...@gmail.comwrote:
On Jul 31, 10:22 pm, ravi <dceravigu...@gmail.comwrote:
Can any body tell me
How to implement a stack using two queues
Thax in advance

Don't you mean implement a queue using 2 stacks, which is a standard
homework problem?
No
It is How to implement a stack using two queues

Aug 1 '07 #3
ravi wrote:
On Aug 1, 7:31 am, Gene <gene.ress...@gmail.comwrote:
>>On Jul 31, 10:22 pm, ravi <dceravigu...@gmail.comwrote:

>>>Can any body tell me
>>>How to implement a stack using two queues
>>>Thax in advance

Don't you mean implement a queue using 2 stacks, which is a standard
homework problem?


No
It is How to implement a stack using two queues
Which is almost certainly also a homework question...
Aug 1 '07 #4
CoL
On Aug 1, 7:22 am, ravi <dceravigu...@gmail.comwrote:
Can any body tell me

How to implement a stack using two queues

Thax in advance
Hi ,
I am just giving you hint for its possible algo.

1. Use one queue to push data into...say Q-a.Make a common push() and
pop() common function passing front and rear initially NULL.

2. For pop operation,
if (Q-a.front!=Q-a.rear)
{
pop and add to Q-b;
}
else
{
pop(); //this is our output
Q-a.front=Q-b.front
Q-a.rear=Q-b.rear;
Q-b.front=Q-b.rear=NULL
}

Hope this helps.

~Col

Aug 1 '07 #5
ravi wrote:
How to implement a stack using two queues?
You need to define 'stack' and 'queue'.
Aug 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Charles Law | last post by:
This is going to seem like a basic OO question, but it comes up and bites me every now and again. Suppose we have a multi-tiered protocol to implement, what is the logical, OO way to design the...
7
by: unified | last post by:
Ok, I'm working on a program that is supposed to compare each letter of a string that is put into a stack and a queue. It is supposed to tell whether or not a word is a palindrome or not. (a...
14
by: Webbee | last post by:
I have a service built that is trying to read messages from a private que. When this tries to happen I get this error.... A workgroup installation computer does not support the operation From...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
4
by: deanfamily | last post by:
I have a rather pecurliar C++ assignment. I need to create a program (using a stack or queue) to verify if the grouping symbols in an arithmetic expression match. For example: {25 + (3 - 6) * 8}...
2
by: hakimks | last post by:
You are provided with a sample C programs: calc.c, which implements a reverse polish notation calculator. Study it carefully. This program uses a stack (of course!) but the stack implementation is...
7
by: DevNull | last post by:
Hello everyone, I decided to pick c++ back up after not really having used it much in 10 years. Just as a point of refference, there was no standard C++ last time I used regularly. Anyways...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
2
by: Mr. Arnold | last post by:
I mean the ability to call a Web service or a WCF service with Service Broker using CLR code that's running on SQL server is very good. I am programming this in a project for a client that's being...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.