answersLogoWhite

0


Best Answer

One.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many stacks needs to implement queue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How many stacks did the Titanic have?

Four stacks. The boilers used 3 of the stacks for exhaust, the fourth was used to vent Titanics' numerous kitchens and galleys.


There is a long queue at the primark store Charlie is 4th from the front and 9th from the end How many people are there in the queue?

12


Write a program in c language to reverse elements of a queue?

There are many ways to reverse the order of the elements in a queue. Provided that you have access to the implementation of the queue, it is of course easy to read the elements from the tail end rather than the front end, thus reversing the elements. However, considering the queue as a black box, and assuming the queue only allows for its characteristic operations (removal of head element, addition to tail), the best method to reverse the elements in a queue to engage a stack. You'd remove the elements from the queue (always reading the head of the queue), and push each element onto the stack. When the queue is empty, you reverse that process: pop each element from the stack until it is empty, and add each element in this order to the end of the queue. Your queue will have the exact same elements as in the beginning, but in reverse order. The exact implementation of this in C, or in any other programming language, is trivial, but the exact source code depends on the implementation of queue and stack containers. Following is pseudocode: Queue<Item> reverse (Queue<Item> queue) { Stack<Item> stack; Item item; while (queue.remove(&item)) { stack.push(item); } while(stack.pop(&item)) { queue.add(item); } return queue; }


What does it means in computer algorithm while empty Q Q1 where Q is queue and Q1 is element of queue?

That doesn't make much sense. I guess it should be while NOT empty Q. Note that in many programming languages, the "not" is expressed with the exclamation mark. Perhaps you overlooked it... or it disappeared from the question. In that case (not empty), the meaning would be something like: while there is something in the queue (i.e., while not empty queue), process the elements in the queue (do something with the element). The statement is incomplete; instead of just "q1" it should say something like "process q1" or "q1.process()".


What are the primitive operation perform on a stack and queue?

Primitive Operations : enqueue(o) Put object o on the end of the queue. dequeue() Remove and return the object at the front of the queue. head() Reveal the front object in the queue, but do not remove it. size() Return the number of objects currently in the queue. capacity() Return the maximum number of objects the queue can hold. Other operations can be defined in terms of these primitive on es. For example: • isEmpty() can be defined by testing whether size() is 0. • isFull() can be defined by testing whether size() equals the capac- ity(). These last two could also be considered primitive operation s. There is a balance between minimizing the set of primitive operation s, versus providing many convenient operations for users.

Related questions

How many minimum no of queues Rae needed to implement priority queue?

Two possible solutions: 1. Separated queue for every possible priority value. 2. One shared queue for every elements, sorted by priority.


How many stacks of 100 dollar bills are in 193000000?

193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks. 193,000,000/100 = 1,930,000 stacks.


How many pages does Jumping the Queue have?

Jumping the Queue has 203 pages.


How many pages does The Queue - novel - have?

The Queue - novel - has 280 pages.


How many syllables does the word queue have?

Queue is a one-syllable word.


How many stacks did the Titanic have?

Four stacks. The boilers used 3 of the stacks for exhaust, the fourth was used to vent Titanics' numerous kitchens and galleys.


How many syllables do queue have?

One


How many stacks of 100 pennies in 10000000?

There would be 100,000 stacks of 100 pennies in 10,000,000.


There is a long queue at the primark store Charlie is 4th from the front and 9th from the endhow many people are there in a queue?

12


There is a long queue at the primark store Charlie is 4th from the front and 9th from the end How many people are there in the queue?

12


If 0.15 is a stack of paper how many stacks of paper would be equal to 6.5?

43 stacks and one third of a stack.


How many stacks of newspaper do you use a day?

none....