C++ Queue: Exercises, Practice, Solution
This resource offers a total of 135 C++ Queue problems for practice. It includes 27 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
[An Editor is available at the bottom of the page to write and execute the scripts.]
From Wikipedia,
In computer science, a queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence. By convention, the end of the sequence at which elements are added is called the back, tail, or rear of the queue, and the end at which elements are removed is called the head or front of the queue, analogously to the words used when people line up to wait for goods or services.
1. Queue Using Array with Enqueue/Dequeue and Status Check
Write a C++ program to implement a queue using an array with enqueue and dequeue operations. Find the top element of the stack and check if the stack is empty, full or not.
2. Reverse Queue Elements
Write a C++ program to reverse the elements of a queue.
3. Sort Queue Elements
Write a C++ program to sort the elements of a queue.
4. Sum of Queue Elements
Write a C++ program to find the sum of all elements of a queue.
5. Average of Queue Elements
Write a C++ program to find the average of all elements of a queue.
6. Median of Queue Elements
Write a C++ program to find the median of all elements of a queue.
7. Mode of Queue Elements
Write a C++ program to find the mode of all elements of a queue.
8. Mean, Variance, and Standard Deviation of Queue Elements
Write a C++ program to find the mean, variance and standard deviation of all elements of a queue.
9. Maximum Element in a Queue
Write a C++ program to find the maximum element of a queue.
10. Minimum Element in a Queue
Write a C++ program to find the minimum element of a queue.
11. Second Highest Element in a Queue
Write a C++ program to find the second highest element of a queue.
12. Second Lowest Element in a Queue
Write a C++ program to find the second lowest element of a queue.
13. Remove a Given Element from a Queue
Write a C++ program to remove a given element from a queue.
14. Remove All Elements from a Queue
Write a C++ program to remove all the elements from a queue.
15. Remove All Even Elements from a Queue
Write a C++ program to remove all even elements from a queue.
16. Remove All Odd Elements from a Queue
Write a C++ program to remove all odd elements from a queue.
17. Remove All Duplicate Elements from a Queue
Write a C++ program to remove all duplicate elements from a queue.
18. Remove All Elements Greater Than a Number from a Queue
Write a C++ program to remove all elements greater than a number from a queue.
19. Concatenate Two Queues
Write a C++ program to concatenate two queues.
20. Copy One Queue to Another
Write a C++ program to copy one queue to another.
21. Find Top and Bottom Elements of a Queue
Write a C++ program to find the top and bottom elements of a queue.
22. Get the Nth Element from the Bottom of a Queue
Write a C++ program to get the Nth element from the bottom of a queue.
23. Get the Nth Element from the Top of a Queue
Write a C++ program to get the Nth element from the top of a queue.
24. Find the Position of an Element in a Queue
Write a C++ program to find the position of an element in a queue.
25. Check if Two Queues are Equal
Write a C++ program to check if two queues are equal.
26. Find the Intersection of Two Queues
Write a C++ program to find the intersection of two queues.
27. Find the Union of Two Queues
Write a C++ program to find the union of two queues.
CPP Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.