answersLogoWhite

0

A queue is a FIFO data structure. The best way to implement this is to use two pointers, one to track the head and one to track the tail. During a push operation, the tail pointer will advance one spot as the data is entered into the list. During a pop operation, the head pointer will advance one spot as data is removed. When the two pointers are pointing to the same space, the queue is empty.

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

Array implementation of priority queue example program in c plus plus?

yes


A program for queue ADT by using arrays in c plus plus?

Arrays are not suitable for implementing queues because while they are ideal for adding to the end, the are not ideal for extraction from the beginning. For that you need a deque. Regardless, the STL (standard template library) already provides an efficient queue ADT in std::queue.


Has C got a built-in queue library?

No.


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; }


How do you simulate mouse clicks in c plus plus?

The easy way is to simply invoke the relevant message handlers. If you wish to simulate mouse clicks within another application, however, post the relevant messages to the operating system's message queue. The OS will pass them to the appropriate application.

Related Questions

Array implementation of priority queue example program in c plus plus?

yes


A program for queue ADT by using arrays in c plus plus?

Arrays are not suitable for implementing queues because while they are ideal for adding to the end, the are not ideal for extraction from the beginning. For that you need a deque. Regardless, the STL (standard template library) already provides an efficient queue ADT in std::queue.


Has C got a built-in queue library?

No.


List out atleast 5 real life instances where queue and circular queue operations are being used?

A>People will stand on queue for getting a film tickets. B>In Airport the luggage will be flowing in a queue manner. C>Children will walk into the school in queue. D>Getting into the temple we have to stand in a queue. E>School children will do the prayer with a proper queue.


How do you detect mouse click globally in C plus plus?

Since most modern operating systems are event-driven you'd need to hook into the system message queue in order to intercept mouse-clicks globally.


How does the round robin algorithm work?

There is a Queue of processes that need to work on and each process has it's time requirement to complete,eg:process processor timeA 3B 8C 6D 4if the processor give 1 processor time to each process , then A->B->C->D will run each taking 1 processor time and complete a cycle and each process that is not complete will add to the end of the queue, if a process is completed it will remove from the queue(not enqueueing).This process will continue until all the process are completed and the queue is empty.Above que will work as follows.A->B->C->D->A->B->C->D->A->B->C->D>B->C->D->B->C->B->C->B->B-> Que is emptyin each highlighted position process that complete their process time remove from the queue and therefore the rest are processing according to queue.


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 is b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c


What is c plus c plus 2c plus c plus c equal?

c + c + 2c + c + c = 6c


B plus b plus b plus c plus c plus c plus c equals?

b + b + b + c + c + c + c = 3b + 4c


Symplify c plus c plus c plus c?

4c


What is c plus c plus c plus c plus c?

c + c + c + c + c = 5 * c.