Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 15RQE
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 18 Solutions
Starting Out with C++: Early Objects (9th 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 - The STL stack is considered a container adapter....Ch. 18 - What types may the STL stack be based on? By...
Ch. 18 - Prob. 7RQECh. 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 - Prob. 17RQECh. 18 - Prob. 18RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PCCh. 18 - Prob. 8PCCh. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Prob. 12PCCh. 18 - Prob. 13PCCh. 18 - Prob. 14PCCh. 18 - Prob. 15PC
Knowledge Booster
Similar questions
- 10) Show the contents of a queue after performing the following operations: ENQUEUE (10)- ENQUEUE (20); DEQUEUE; ENQUEUE (30); ENQUEUE (40); DEQUEUE.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
- 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_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_forwardQuestion in image. Please explain how to do the Question with the answer. Thank youarrow_forward
- c++ 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_forward3. Write a program to implement a queue and perform the following operations on a queue: enqueue(800), enqueue(100), dequeue( ), enqueue(300), enqueue(500), dequeue( ), dequeue( ).arrow_forwardFollowing 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_forward
- Please answer the question in image. Please don't add anything extra Thank you.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_forwardC++ ProgrammingActivity: Queue Linked List Explain the flow of the code not necessarily every line, as long as you explain what the important parts of the code do. The code is already correct, just explain the flow. SEE ATTACHED PHOTO FOR THE PROBLEM #include "queue.h" #include "linkedlist.h" class SLLQueue : public Queue { LinkedList* list; public: SLLQueue() { list = new LinkedList(); } void enqueue(int e) { list->addTail(e); return; } int dequeue() { int elem; elem = list->removeHead(); return elem; } int first() { int elem; elem = list->get(1); return elem;; } int size() { return list->size(); } bool isEmpty() { return list->isEmpty(); } int collect(int max) { int sum = 0; while(first() != 0) { if(sum + first() <= max) { sum += first();…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