Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 19, Problem 25RQE
Program Plan Intro
Queue:
- A queue contains sequence of items.
- The item which is inserted first is retrieved first.
- Queue performs “First In First Out”.
Operations performed on Queue:
A queue can perform two operations. They are:
- Enqueue
- Dequeue
Enqueue:
Insertion of an element into the queue is called as Enqueue. The elements can be inserted at any end of the queue. The sides in which the items are inserted are called as “Rear”.
Dequeue:
Retrieving an element from the queue is known as Dequeue. The sides in which the items are retrieved are called as “Front”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Suppose the following operations are performed on an empty queue:enqueue(5);enqueue(?);dequeue();enqueue(9);enqueue ( 12);dequeue();enqueue(10);Insert numbers in the following diagram to show what will be stored in the staticqueue after the operations have executed .front rear
Note : addqueue works like Enqueue and deleteQueue works like Dequeue
Consider the following statements: (8, 9)
queueType queue;
int num;
Show what is output by the following segment of code
num = 7;
queue.addQueue (6);
queue.addQueue (num);
num = queue.front ();
queue.deleteQueue();
queue.addQueue (num + 5);
queue.addQueue (14);
queue.addQueue (num
queue.addQueue (25);
queue.deleteQueue ();
2);
cout <« "Queue elements: ";
while (!queue.isEmptyQueue ())
{
cout <« queue.front () << " ";
queue.deleteQueue();
}
cout <« endl;
Queue elements: 14 14 4 25
Queue elements: 11 14 4 4
Queue elements: 11 14 4 25
Queue elements: 11 14 25 25
java data structure
Queue:
Q4: A program performs the following operations on an empty queue Q:
Q.enqueue(24)
Q.enqueue(74)
Q.enqueue(34)
Q.first()
Q.dequeue()
Q.enqueue(12)
Q.dequeue()
Please show the queue contents at the end of these operations. Clearly show the front of the queue.
Chapter 19 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 19.1 - Describe what LIFO means.Ch. 19.1 - What is the difference between static and dynamic...Ch. 19.1 - What are the two primary stack operations?...Ch. 19.1 - What STL types does the STL stack container adapt?Ch. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - What is the difference between a static stack and...Ch. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - The STL stack is considered a container adapter....
Ch. 19 - What types may the STL stack be based on? By...Ch. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - The STL stack container is an adapter for the...Ch. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 21RQECh. 19 - Prob. 22RQECh. 19 - Prob. 23RQECh. 19 - Prob. 24RQECh. 19 - Prob. 25RQECh. 19 - Prob. 26RQECh. 19 - Write two different code segments that may be used...Ch. 19 - Prob. 28RQECh. 19 - Prob. 29RQECh. 19 - Prob. 30RQECh. 19 - Prob. 31RQECh. 19 - Prob. 32RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Dynamic String Stack Design a class that stores...Ch. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PCCh. 19 - Prob. 11PCCh. 19 - Inventory Bin Stack Design an inventory class that...Ch. 19 - Prob. 13PCCh. 19 - Prob. 14PCCh. 19 - Prob. 15PC
Knowledge Booster
Similar questions
- b. Write out the order of elements that are contained in a queue after the following operations are performed. myQueue.enqueue(new Integer(16)); myQueue.enqueue(new Integer(12)); Integer num1 = myQueue.dequeue(); myQueue.enqueue(new Integer(6)); myQueue.enqueue(new Integer(8)); myQueue.enqueue(new Integer(30)); myQueue.enqueue(new Integer(24)); myQueue.enqueue(new Integer(18)); myQueue.dequeue(); myQueue.dequeue(); myQueue.dequeue(); myQueue.enqueue(new Integer(38); Show how step by step process of arriving at your answer.arrow_forwardA queue and a deque data structure are related concepts. Deque is an acronym meaning "double-ended queue." With a deque, you may insert, remove, or view from either end of the queue, which distinguishes it from the other two. Use arrays to implement a dequearrow_forwardExplain how a queue works along with the enqueue and dequeue operations with front and rear pointers.arrow_forward
- Question in image. Please explain how to do the Question with the answer. Thank youarrow_forward1 Implement a Queue Data Structure specifically to store integer data using a Singly Linked List. 2 The data members should be private. 3 You need to implement the following public functions: 4 1. Constructor: 5 It initialises the data members as required. 6 7 8 2. enqueue(data) : This function should take one argument of type integer. It enqueues the element into the queue and returns nothing. 3. dequeue(): It dequeues/removes the element from the front of the queue and in turn, returns the element being dequeued or removed. In case the queue is empty, it r 4. front (): 10 11 It returns the element being kept at the front of the queue. In case the queue is empty, it returns -1. 12 5. getSize(): 13 It returns the size of the queue at any given instance of time. 14 6. 1sEmpty(): 15 It returns a boolean value indicating whether the queue is empty or not. 16 Operations Performed on the Stack: 17 Query-1 (Denoted by an integer 1): Enqueues an integer data to the queue. 18 19 Query-2…arrow_forward3- Write a program that randomly generates 10 numbers (between 1 and 8), inserts into queue and then finds how many distinct elements exist in the queue. Example 1: Example 2: Queue: 2 40 3 3 2 18 4 18 18 3 Queue: 1 1 4 33 16 16 4 16 4 Output: 5 Output: 4 Notes: • You must use ONLY queue data structure. Don't use other different data structures like string or normal (pure) array or stack or array list. • Don't write any other method in the Qeueu class. All methods must be written in the main program.arrow_forward
- C++ Programarrow_forwardIf a queue is empty, Select one: A.You can dequeue an element from the queue B.The size of the queue is 1 C.You cannot enqueue an element into the queue. D.You cannot dequeue an element from the queue.arrow_forwardc++ Write a client function that returns the back of a queue while leaving the queue unchanged. This function can call any of the methods of the ADT queue. It can also create new queues. The return type is ITemType, and it accepts a queue as a parameter.arrow_forward
- Please answer question 4.2 the reference question is also given. Please explain how to get the answer with the answer. If can please give answer and explaining as two parts. Thank you.arrow_forwardPlease answer the question in image. Please don't add anything extra Thank you.arrow_forwardQ1- Write a program that create two objects (C, D) from the queue class and do the following: Add 100 elements to queue C by results of muiplication table from (1 to 10) Add 10 elements to queue D by summation the results of cach table alone.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning