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 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Stacks and Queues are called
data structures because their operations are specialized.
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
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
- 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();…arrow_forwardP7arrow_forwardDifferentiate between ArrayList and LinkedList.arrow_forward
- Data structure & alogrithum java program Create a corresponding DRIVER/Tester class that performs the following steps: 1. Create an instance of this deque containing a list of string data-type2. Check if deque is empty3. Display who is in the front and who is in the back4. Add 6 elements to this queue containing a list of people's First and Last Names (your friends, family, Tv Show characters, sports) by adding some to the front and some to the back5. Check if the queue is empty6. Display who is in the front and who is in the back7. Remove the person on the front and the person in the back8. Display who is in the front and who is in the back9. Clear all elements in the queue10. Check if the queue is emoty11. Display who is in the front and who is in the backarrow_forward# Create an object from the Queue class. # Queue (with a capital Q) is the class name # queue (with a small q) is the object # created from the "Queue" classarrow_forwarddata structure Create a Java program using a Linked list by adding 5 nodes and then removing 1 node from the list. The node entries can be either Numbers (Int) or Characters (String).arrow_forward
- c++ data structures ADT Unsorted List The specifications for the Unsorted List ADT states that the item to be deleted is in the list. Rewrite the specifications for DeleteItem so that the list is unchanged if the item to be deleted is not in the list. Rewrite the specifications for DeleteItem so that all copies of the item to be deleted are removed if they existarrow_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. #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(); dequeue(); } else {…arrow_forwardjava programing Design an inventory class that stores the following members serialNum: an integer that holds a part’s serial number manufactDate: a member that holds the date the part was manufactured lotNum: an integer that holds the part’s lot number The class should have appropriate member functions (interfaces) for storing data into, and retrieving data from, these members. Then, design a program that uses the queue class. The type of the queue should be the above inventory. The program should have a loop that asks the user whether he or she wishes to add a part to inventory or take a part from inventory. The loop should repeat until the user is finished. If the user wishes to add a part to inventory, the program should ask for the serial number, date of manufacture, and lot number. The information should be stored in an inventory object using inventory interfaces and added into the inventory queue. If the user wishes to take a part from inventory, the program should remove the…arrow_forward
- C++ Queue LinkedList, Refer to the codes I've made as a guide and add functions where it can add/insert/remove function to get the output of the program, refer to the image as an example of input & output. Put a comment or explain how the program works/flow.arrow_forwardjava programming Write two methods in the Java programming language, the first using recursion to find the smallest item in the list and the second the largest. Name the methods appropriately. class OurList{ int head; OurList tail; //methods }arrow_forwardJava data strucarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning