Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 14RQE
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
Explain how a queue works along with the enqueue and dequeue operations with front and rear pointers.
Chapter 18 Solutions
Starting Out with C++: Early Objects
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. 13PC
Knowledge Booster
Similar questions
- Question in image. Please explain how to do the Question with the answer. Thank youarrow_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_forward10) Show the contents of a queue after performing the following operations: ENQUEUE (10)- ENQUEUE (20); DEQUEUE; ENQUEUE (30); ENQUEUE (40); DEQUEUE.arrow_forward
- C++ Programarrow_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_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_forwardPlease 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_forward
- What operations are possible with queues?arrow_forwardThe data structure that allows for elements to be added and removed at both ends but not in the middle is called: 1.Double-ended Queue. 2.Priority Queue. 3.Duck. 4.Torque.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_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