Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 24RQE
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 deleted are called as “Front”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
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
Question in image.
Please explain how to do the Question with the answer.
Thank you
Chapter 18 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 18.3 - Describe what LIFO means.Ch. 18.3 - What is the difference between static and dynamic...Ch. 18.3 - What are the two primary stack operations?...Ch. 18.3 - What STL types does the STL stack container adapt?Ch. 18 - Prob. 1RQECh. 18 - Prob. 2RQECh. 18 - What is the difference between a static stack and...Ch. 18 - Prob. 4RQECh. 18 - Prob. 5RQECh. 18 - The STL stack is considered a container adapter....
Ch. 18 - What types may the STL stack be based on? By...Ch. 18 - Prob. 8RQECh. 18 - Prob. 9RQECh. 18 - Prob. 10RQECh. 18 - Prob. 11RQECh. 18 - Prob. 12RQECh. 18 - Prob. 13RQECh. 18 - Prob. 14RQECh. 18 - Prob. 15RQECh. 18 - Prob. 16RQECh. 18 - The STL stack container is an adapter for the...Ch. 18 - Prob. 18RQECh. 18 - Prob. 19RQECh. 18 - Prob. 20RQECh. 18 - Prob. 21RQECh. 18 - Prob. 22RQECh. 18 - Prob. 23RQECh. 18 - Prob. 24RQECh. 18 - Prob. 25RQECh. 18 - Prob. 26RQECh. 18 - Write two different code segments that may be used...Ch. 18 - Prob. 28RQECh. 18 - Prob. 29RQECh. 18 - Prob. 30RQECh. 18 - Prob. 31RQECh. 18 - Prob. 32RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Dynamic String Stack Design a class that stores...Ch. 18 - Prob. 7PCCh. 18 - Prob. 8PCCh. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Inventory Bin Stack Design an inventory class that...Ch. 18 - Prob. 13PCCh. 18 - Prob. 14PCCh. 18 - Prob. 15PC
Knowledge Booster
Similar questions
- Explain how a queue works along with the enqueue and dequeue operations with front and rear pointers.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_forwardC++ Programarrow_forward
- 3- 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_forward10) Show the contents of a queue after performing the following operations: ENQUEUE (10)- ENQUEUE (20); DEQUEUE; ENQUEUE (30); ENQUEUE (40); DEQUEUE.arrow_forwardPlease 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_forward
- Please answer the question in image. Please don't add anything extra Thank you.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_forwardComputer Science A string represents a sequence of operations to be performed when implementing the Queue ADT. Theletter means the "put" operation, the asterisk means the "get" operation. What will remain in the queueafter performing the above operations? DB**KK*R**arrow_forward
- Following initial state of a queue is reflecting the implementation of a circular array. The front and back pointers are shown on the queue. 67 32 45 b. enqueue(95) c. dequeue front Show the queue state after each of the following operations with updating front and back pointers as required: a. enqueue(23) d. dequeue e. enqueue(11) f. dequeue g. dequeue h. dequeue 44 backarrow_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_forwardb. 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_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education