
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 18, Problem 2P
Program Plan Intro
Histogram of positive numbers
Program Plan:
- Include required header file.
- Include required “std” namespace.
- Define main function
- Declare a variable in “map” template class.
- Initializes the variable “numbers” to “0”.
- Display prompt statement.
- Performs “while” loop. This loop will perform upto “numbers” equal to “-1”.
- In this loop, first read the number from user.
- If the number is not equal to “-1”, then check if the number is in map or not using “find” function.
- If it is, then assign “mapResult[numbers]” is “1”.
- Otherwise, increment the counter
- Declare constant iter “result” in “map” template class.
- Display the given result using “for” loop.
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Students have asked these similar questions
Can you check if my explation is correct:
Challenge: Assume that the assigned network addresses are correct. Can you deduce (guess) what the network subnet masks are? Explain while providing subnet mask bits for each subnet mask.
[Hint: Look at the addresses in binary and consider the host ids]
To assume that the network addresses are correct, we take a look at the network ID and IP addresses. Take 20.0.0.0/8, we have an /8 prefix which is Class A, that provide us with 255.0.0.0. This means that there are 24 host bits while the network bits are 8. When compared to the IP address 20.255.0.7, we can perform an additional operation with the subnet mask giving us 20.0.0.0. The same happened with 20.0.0.89, which we also got 20.0.0.0. Therefore, these two IP addresses fall within the respective /8 subnet. For 200.100.10.0/30, the /30 is Class C with a subnet mask of 255.255.255.252, meaning 30 network bits and only two host bits. When applying the subnet mask and the IP addresses…
It is possible to sort an array of n values using pipeline of n filter processes.The first process inputs all the values one at a time, keep the minimum, and passes the others on to the next process. Each filter does the same thing; it receives a stream of values from the previous process, keep the smallest, and passes the others to the next process. Assume each process has local storage for only two values--- the next input value and the minimum it has seen so far.
(a) Developcode for filter processes. Declare the channels and use asynchronous message passing.
Hint:Define an array of channels value[n] (int), and a set of filter processes Filter[i = 0 ton-1]. Each process Filter[i] (where 0 <= i <= n-2) receives a stream of integers through channelvalue[i], keeps the smallest, and sends all other integers to channel value[i+1]. The last processFilter[n-1] receives only one integer through channel value[n-1] and does not need to send anyinteger further.
It is possible to sort an array of n values using pipeline of n filter processes.The first process inputs all the values one at a time, keep the minimum, and passes the others on to the next process. Each filter does the same thing; it receives a stream of values from the previous process, keep the smallest, and passes the others to the next process. Assume each process has local storage for only two values--- the next input value and the minimum it has seen so far.
(a) Developcode for filter processes. Declare the channels and use asynchronous message passing.
Hint:Define an array of channels value[n] (int), and a set of filter processes Filter[i = 0 ton-1]. Each process Filter[i] (where 0 <= i <= n-2) receives a stream of integers through channelvalue[i], keeps the smallest, and sends all other integers to channel value[i+1]. The last processFilter[n-1] receives only one integer through channel value[n-1] and does not need to send anyinteger further.
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- It is possible to sort an array of n values using pipeline of n filter processes.The first process inputs all the values one at a time, keep the minimum, and passes the others on to the next process. Each filter does the same thing; it receives a stream of values from the previous process, keep the smallest, and passes the others to the next process. Assume each process has local storage for only two values--- the next input value and the minimum it has seen so far. (a) Developcode for filter processes. Declare the channels and use asynchronous message passing. Hint:Define an array of channels value[n] (int), and a set of filter processes Filter[i = 0 ton-1]. Each process Filter[i] (where 0 <= i <= n-2) receives a stream of integers through channelvalue[i], keeps the smallest, and sends all other integers to channel value[i+1]. The last processFilter[n-1] receives only one integer through channel value[n-1] and does not need to send anyinteger further.arrow_forwardIt is possible to sort an array of n values using pipeline of n filter processes.The first process inputs all the values one at a time, keep the minimum, and passes the others on to the next process. Each filter does the same thing; it receives a stream of values from the previous process, keep the smallest, and passes the others to the next process. Assume each process has local storage for only two values--- the next input value and the minimum it has seen so far. (a) Developcode for filter processes. Declare the channels and use asynchronous message passing. Hint:Define an array of channels value[n] (int), and a set of filter processes Filter[i = 0 ton-1]. Each process Filter[i] (where 0 <= i <= n-2) receives a stream of integers through channelvalue[i], keeps the smallest, and sends all other integers to channel value[i+1]. The last processFilter[n-1] receives only one integer through channel value[n-1] and does not need to send anyinteger further.arrow_forwardIt is possible to sort an array of n values using pipeline of n filter processes.The first process inputs all the values one at a time, keep the minimum, and passes the others on to the next process. Each filter does the same thing; it receives a stream of values from the previous process, keep the smallest, and passes the others to the next process. Assume each process has local storage for only two values--- the next input value and the minimum it has seen so far. (a) Developcode for filter processes. Declare the channels and use asynchronous message passing. Hint:Define an array of channels value[n] (int), and a set of filter processes Filter[i = 0 ton-1]. Each process Filter[i] (where 0 <= i <= n-2) receives a stream of integers through channelvalue[i], keeps the smallest, and sends all other integers to channel value[i+1]. The last processFilter[n-1] receives only one integer through channel value[n-1] and does not need to send anyinteger further.arrow_forward
- I need help: Challenge: Assume that the assigned network addresses are correct. Can you deduce (guess) what the network subnet masks are? Explain while providing subnet mask bits for each subnet mask. [Hint: Look at the addresses in binary and consider the host ids]arrow_forwardI would like to know if my answer statment is correct? My answer: The main difference is how routes are created and maintained across different networks. Static routing establishes router connections to different networks from the far left and far right. The Dynamic routing focus emphasizes immediate connection within the router while ignoring the other connections from different networks. Furthermore, the static routing uses the subnet mask to define networks such as 25.0.0.0/8, 129.60.0.0/16, and 200.100.10.0/30, which correspond to 255.0.0.0, 255.255.0.0, and 255.255.255.252. On the other hand, dynamic routing uses the wildcard mask to inverse the subnet mask, where network bits become 0 and host bits become 1, giving us 0.0.0.255, 0.0.255.255, and 0.0.0.3. Most importantly, the CLI commands used for Static and Dynamic routing are also different. For static routing, the “IP route” corresponds with the network, subnet mask, and next-hop IP address. In contrast, dynamic routing uses…arrow_forward1. [30 pts] Match the items on the left with the memory segment in which they are stored. Answers may be used more than once, and more than one answer may be required. 1. Static variables 2. Local variables 3. Global variables 4. Constants 5. Machine Instructions 6. malloc() 7. String Literals Answer A. Code B. Static C. Heap D. Stackarrow_forward
- Build an Android App that shows a list of your favorite books' details. The App should have a set of java files that implement an adapter with RecyclerView. The details of the java files you need to create are described below. RecycleViewExample RHONDA BYRNE 2016 Listen to Your Heart: The London Adventure Ruskin Bond 2010 Business of Sports: The Winning Formula for Success Vinit Karnik 2022 A Place Called Home Preeti Shenoy 2018 Vahana Masterclass Alfredo Covelli 2016 The Little Book of Encouragement Dalai Lama 2021 Platform Scale: For A Post-Pandemic World Sangeet Paul Choudary 2021 Unfinished Priyanka Chopra Jonas 2018 1. The first java file should contain a data field which is in this case: Book_name, Author_name, Publication_year. 2. The second java file contains BookViewHolder. 3. The third java file contains the BookAdapter which is act as a bridge between the data items and the View inside of RecycleView. 4. The Mainactivity java file will contain some samples data to display.…arrow_forwardmodule : java Question3: (30 MARKS) Passenger Rail Agency for South Africa Train Scheduling System Problem Statement Design and implement a train scheduling system for Prasa railway network. The system should handle the following functionalities: 1. Scheduling trains: Allow the addition of train schedules, ensuring that no two trains use the same platform at the same time at any station. 2. Dynamic updates: Enable adding new train schedules and canceling existing ones. 3. Real-time simulation: Use multithreading to simulate the operation of trains (e.g., arriving, departing). 4. Data management: Use ArrayList to manage train schedules and platform assignments. Requirements 1. Add Train Schedule, Cancel Scheduled Train, View Train Schedules and Platform Management 2. Concurrency Handling with Multithreading i.e Use threads to simulate train operations, Each…arrow_forwardQuestion D.4: FIFO Page Replacement Consider the following page reference string: e, c, b, e, a, g, d, c, e, g, d, a Considering 4 frames, fill in the following table and then answer how many page faults would occur with the FIFO page replacement algorithm. RS: reference string; FO: frame 0, F1: frame 1, etc. Hint: all frames are initially empty, so your first unique pages will all cost one fault each. Time 1234567891011 12 RS e cb e agd ce g d a FO F1 F2 F3 Page fault? b) Total # page faults: c) Briefly (1-2 sentences) explain Belady's Anomaly that can occur in FIFO Page Replacement.arrow_forward
- Consider a system that uses a fixed-partition scheme, with equal partitions of size 2" bytes, and the main memory has 2¹8 bytes. A process table is maintained with a pointer to the resident partition for each resident process. How many bits are required for the pointer in the process table? Show all your steps.arrow_forwardUse the same semaphore notation shown above to describe how we can ensure the execution order of the following process execution graph: P6 P2 P7 P1 P3 P4 P5 Use all of the following semaphores in your answer: s1=0; s2=0; s3=0; s4=0; s5=0; s6=0;arrow_forwardConsider the set of process: Process ID Arrival Time Burst Time P1 0 5 P2 0 10 P3 + 15 P4 18 10 P5 22 20 a) Draw the GANTT chart for the Round Robin time quantum -5) scheduling algorithm. Use the same implementation you used for the programming assignmenti.e. the processes should always run in PID order. Assume there is no context-switch overhead. Show your work for partial credit. b) Write your answer to the following performance metrics given your above CANTT charts. Show your work for partial credit. Average Response time: Average Wating time: Average Turnaround time: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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT

C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr

Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage

EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT