Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 18.2, Problem 12STE
Explanation of Solution
Queue adapter template class:
- No iterator in the queue adepter template class.
- Therefore, three iterators such as forward, bidirectional or random iterator does not have in this template adapter class.
- Type name for queue of type “T” elements is “queue<T&...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Implement a LinkedList class that stores integers using dynamic memory and a proper main program to test it.
The following member functions need to be properly implemented and tested:
1. Default constructor.
2. Parmetrized Constructor.
3. Sum.
4. Average.
5. InsertAtHead.
6. InsertAtTail.
7. Delete.
8. Pop.
9. Circular.
10. Display.
Sample answer is also provided.
Create a class called ResizingArrayQueueOfStrings that implements the queue abstraction using a fixed-size array. Then, as an extension, utilise array resizing in your implementation to get rid of the size constraint.
Given the linked list data structure, implement a sub-class TSortedList that makes sure that elements are inserted and maintained in an ascending order in the list. So, given the input sequence {1,7,3,11,5}, when printing the list after inserting the last element it should print like 1, 3, 5, 7, 11. Note that with inheritance, you have to only care about the insertion situation as deletion should still be handled by the parent class.
Chapter 18 Solutions
Problem Solving with C++ (10th Edition)
Ch. 18.1 - If v is a vector, what does v.begin() return? What...Ch. 18.1 - If p is an iterator for a vector object v, what is...Ch. 18.1 - Suppose v is a vector of ints. Write a for loop...Ch. 18.1 - Suppose the vector v contains the letters 'A',...Ch. 18.1 - Suppose the vector v contains the letters 'A',...Ch. 18.1 - Suppose you want to run the following code, where...Ch. 18.2 - Prob. 7STECh. 18.2 - Prob. 8STECh. 18.2 - Prob. 9STECh. 18.2 - Prob. 10STE
Ch. 18.2 - Prob. 11STECh. 18.2 - Prob. 12STECh. 18.2 - Prob. 13STECh. 18.2 - Prob. 14STECh. 18.2 - Prob. 15STECh. 18.2 - Prob. 16STECh. 18.3 - Prob. 17STECh. 18.3 - Prob. 18STECh. 18.3 - Prob. 19STECh. 18.3 - Suppose v is an object of the class vectorint. Use...Ch. 18.3 - Prob. 21STECh. 18.3 - Can you use the copy template function with vector...Ch. 18.3 - Prob. 23STECh. 18 - Prob. 1PCh. 18 - Prob. 2PCh. 18 - Prob. 3PCh. 18 - Prob. 4PCh. 18 - Write a program that allows the user to enter any...Ch. 18 - Prob. 3PPCh. 18 - Prob. 5PPCh. 18 - Solution to Programming Project 18.6 In this...Ch. 18 - Prob. 7PPCh. 18 - You have collected a file of movie ratings where...Ch. 18 - Prob. 9PPCh. 18 - Prob. 11PPCh. 18 - Write a program that uses regular expressions to...
Knowledge Booster
Similar questions
- Write code in C++ using linked listarrow_forwardplease convert this into c++ import java.util.Iterator;import java.util.NoSuchElementException; public class Queue<Item> implements Iterable<Item> { private int n; // number of elements on queue private Node first; // beginning of queue private Node last; // end of queue // helper linked list class private class Node { private Item item; private Node next; } /** * Initializes an empty queue. */ public Queue() { first = null; last = null; n = 0; } /** * Returns true if this queue is empty. * * @return {@code true} if this queue is empty; {@code false} otherwise */ public boolean isEmpty() { return first == null; } /** * Returns the number of items in this queue. * * @return the number of items in this queue */ public int size() { return n; } /** * Returns the number of items in this queue. * * @return the…arrow_forwardThe agreement between the implementer of a Queue ADT and the programmer who uses it is represented by the Queuelnterface interface. Is it proper or improper?arrow_forward
- Suppose that queue is a queueType object and the size of the array implementing queue is 65. Also, suppose that the value of queueFront is 64 and the value of queueRear is 64. a. How many elements are in queue?b. What are the values of queueFront and queueRear after adding an element to queue?c. What are the values of queueFront and queueRear after removing an element from queue?arrow_forwardStarter code for ShoppingList.java import java.util.*;import java.util.LinkedList; public class ShoppingList{ public static void main(String[] args) { Scanner scnr=new Scanner(System.in); LinkedList<ListItem>shoppingList=new LinkedList<ListItem>();//declare LinkedList String item; int i=0,n=0;//declare variables item=scnr.nextLine();//get input from user while(item.equals("-1")!=true)//get inputuntil user not enter -1 { shoppingList.add(new ListItem(item));//add into shoppingList LinkedList n++;//increment n item=scnr.nextLine();//get item from user } for(i=0;i<n;i++) { shoppingList.get(i).printNodeData();//call printNodeData()for each object } }} class ListItem{ String item; //constructor ListItem(String item) { this.item=item; } void printNodeData() { System.out.println(item); }}arrow_forwardDo it in C++ template (STL)arrow_forward
- CODE IN JAVA You have probably heard about the deque (double-ended queue) data structure, which allows for efficient pushing and popping of elements from both the front and back of the queue. Depending on the implementation, it also allows for efficient random access to any index element of the queue as well. Now, we want you to bring this data structure up to the next level, the teque (triple-ended queue)!arrow_forwardInstruction: To test the Linked List class, create a new Java class with the main method, generate Linked List using Integer and check whether all methods do what they’re supposed to do. A sample Java class with main method is provided below including output generated. If you encounter errors, note them and try to correct the codes. Post the changes in your code, if any. Additional Instruction: Linked List is a part of the Collection framework present in java.util package, however, to be able to check the complexity of Linked List operations, we can recode the data structure based on Java Documentation https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html package com.linkedlist; public class linkedListTester { public static void main(String[] args) { ListI<Integer> list = new LinkedList<Integer>(); int n=10; for(int i=0;i<n;i++) { list.addFirst(i); } for(int…arrow_forwardUsing c++ Create a queue using a linked list as your container and use a class. The system must have enqueue and dequeue operations and functions such as, isfull() and isempty(). Make sure it has an input and 10 data will be accepted. Can anyone show me the correct way i tried some like this ------------------------------------------------------------------------------------- #include <stdio.h>#include <stdlib.h>#include <limits.h> #define CAPACITY 100 typedef struct node { int data; struct node * next;} Queue; unsigned int size = 0; int enqueue(Queue ** rear, Queue ** front, int data);int dequeue(Queue ** front);int getRear(Queue * rear);int getFront(Queue * front);int isEmpty();int isFull(); int main(){ int ch, data; Queue *rear, *front; rear = NULL; front = NULL; while (1) { printf("--------------------------------------------\n"); printf(" QUEUE LINKED LIST IMPLEMENTATION PROGRAM \n");…arrow_forward
- A double-ended queue or deque is a generalization of a stack and a queue that supports adding and removing items from either the front or the back of the data structure. This assignment has two parts: Part-1 Create a doubly linked list based DeQueDLL class that implements the DequeInterface. The class skeleton and interface are provided to you. Implement a String toString () method that creates and returns a string that correctly represents the current deque. Such a method could prove useful for testing and debugging the class and for testing and debugging applications that use the class. Assume each queued element already provides its own reasonable toString method. Part-2 Create an application program that gives a user the following three options to choose from – insert, delete, and quit. If the user selects ‘insert’, the program should accept the integer input from the user and insert it into the deque in a sorted manner. If the user selects ‘delete’, the program should…arrow_forwardCreate a class called ResizingArrayQueueOfStrings that uses the queue abstraction using a fixed-size array. Then, as an extension, use array resizing in your implementation to get rid of the size restriction.arrow_forwardWrite a c++ program that implements a linked list as an abstract datatype. The program must be: *Be type flexibl.,that is,could a list of intergers,string,or any type *Allow the user to add members into the list *Delete members from the list *Make sure the list is still sorted after all deletion and addition *Show all the function implemetationarrow_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