Chapter 10 Exercise Set 0: Chapter ReviewΒΆ

  1. Rerun the how_many experiment from the Counting section with larger values for num_values and describe your results. Try calling srand seeded with the current time. Repeat this several times, documenting your results.

  2. Encapsulate the single pass histogram from the A histogram section in a function named histogram that takes a vector and a range of values in the vector (which was 0 through 9 in the example), and returns a histogram of the values in the vector.

  3. Open a file named random_numbers.dat containing several lines of random integers seperated by spaces, and read them into a vector named numbers. Then use the insertion sort algorithm presented in the Other member functions section to sort these numbers. Finally, open a file named sorted_numbers.dat for writing, and write out your sorted list of numbers to this file.