Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
Chapter 18, Problem 6PC
Program Plan Intro

Dynamic String Queue

Program Plan:

  • Include the required header files.
  • Declare a class Dynque that creates a queue and store all the elements in the queue.
    • Declare all the variables present in the class.
    • Declare the front and rear pointers and the number of items.
    • Create a constructor to allocate elements in queue.
    • Create a destructor to deallocate elements in queue.
    • Create a function void Dynque<T>::enqueue(T val)that inserts the value in the variable val at the rear end of queue.
    • Create a function  void Dynque<T>::dequeue(T &val)that removes the value at the  front of the queue, and copies it into val.
    • Create a boolean function to check if queue is empty and a function clear to dequeue all elements present in the queue.
  • Declare the main function.
    • Prompt the user to enqueue 5 strings into the queue.
    • Dequeue and retrieve all items present in the queue.

Blurred answer
Students 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.
None
C++ 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();…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education