c++ question  Problem statement Often some data sets are acquired in a regular basis. For example daily daytime average temperature in a year in a city. Imagine in a situation in which we are more interested in finding out the highest daily daytime average temperature of the year and the respective day. We can design the data acquisition so that we always keep the current maximum in a specific location of the array usually at the top or at the bottom as we receive data. Assume we keep the maximum at the bottom. Now we check the incoming data set against the current maximum at bottom and if the incoming is larger we add it to the end of the array. Otherwise we insert it to the position above the maximum. This way at the end of the data collection, we automatically collect the data we are most interested at the end of the array. This prevents expensive search operations to find the maximum; it is now a single CPU instruction to access as we know it's location (imagine trying to locate a data point in among millions of data compared to directly accessing it). A C++ vectors (std::vector) provide ideal data structure for this purpose as it can grow dynamically. Your task here is to write a function named, update_temp to update a C++ vector to keep the maximum data value passed, always at the end of the vector. A single data element must be a std::pair object with first item being the day number (1- 365) and second item is daily daytime average temperature. To mimic the daily data collection, you are given a randomly generated array of daily temperatures of length 365. So if you access the array sequentially from top to bottom, you can imagine one access is similar to recording the daily daytime average temperature for that particular day. Given this array, generate the vector. Do the following Write your algorithm as code comments. I recommend to follow UMPIRE technique ). Implement your function. For your convenience, you are given the function declaration (. In your driver program, test your function and print only the last 5 data values along with day number  You must print your dataset exactly as shown below including data values showing maximum daytime average daily temperature of 99.7843 units occurred on 78th day. Day | Temperature ===================== 362|82.8049 363|79.172 364|31.91 365|86.7245 78|99.7843

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 44SA
icon
Related questions
Question

c++ question 

Problem statement

Often some data sets are acquired in a regular basis. For example daily daytime average temperature in a year in a city. Imagine in a situation in which we are more interested in finding out the highest daily daytime average temperature of the year and the respective day. We can design the data acquisition so that we always keep the current maximum in a specific location of the array usually at the top or at the bottom as we receive data. Assume we keep the maximum at the bottom. Now we check the incoming data set against the current maximum at bottom and if the incoming is larger we add it to the end of the array. Otherwise we insert it to the position above the maximum. This way at the end of the data collection, we automatically collect the data we are most interested at the end of the array. This prevents expensive search operations to find the maximum; it is now a single CPU instruction to access as we know it's location (imagine trying to locate a data point in among millions of data compared to directly accessing it). A C++ vectors (std::vector) provide ideal data structure for this purpose as it can grow dynamically.

Your task here is to write a function named, update_temp to update a C++ vector to keep the maximum data value passed, always at the end of the vector. A single data element must be a std::pair object with first item being the day number (1- 365) and second item is daily daytime average temperature. To mimic the daily data collection, you are given a randomly generated array of daily temperatures of length 365. So if you access the array sequentially from top to bottom, you can imagine one access is similar to recording the daily daytime average temperature for that particular day. Given this array, generate the vector.

Do the following

  1. Write your algorithm as code comments. I recommend to follow UMPIRE technique ).
  2. Implement your function. For your convenience, you are given the function declaration (.
  3. In your driver program, test your function and print only the last 5 data values along with day number 
    1. You must print your dataset exactly as shown below including data values showing maximum daytime average daily temperature of 99.7843 units occurred on 78th day.
      Day | Temperature
      =====================
      362|82.8049
      363|79.172
      364|31.91
      365|86.7245
      78|99.7843 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr