### Topical Information

This lab will help you practice with dynamic
memory (**NOT** mixed with classes).

### Program Information

One statistic of interest to many researchers is the median of a set of
data. The median is the value in the middle. (This is
**NOT** the average, mind you.) Being in the middle, of
course implies that the data are in order (sorted). If there are an odd
number of data items, the middle is simple to find. If there are an even
number of data items, you are supposed to take the average of the two
middle values.

You'll need to find the median of a set of data from a file. You don't
know how many data are in the file, of course. You'll have to count the
data, then read them in to sort, then find the median, and finally print it
(the median) out.

(BTW, there are three sorts described in the online notes from 121 as well
as the pseudocode for
a *decent* bubble sort
with several suggestions for efficiency tuning.)

Do **NOT** use any more memory than is necessary!!

### Thought Provoking Questions

- What (data) types of values can your program handle?
- How do you count the number of data items which are in the file?
Once you've counted them, how do you start over and read them in?
- How do you allocate memory on the heap? Is it guaranteed to work?
- When do you allocate memory for your values array? Before or after
counting the values in the file?
- When you are done with dynamic memory, what should you do?
- What's this nullptr value for,
anyway?
- Which sorting algorithm did you use? How efficient is it?
(i.e. What is it's complexity?)
- Does it matter if the data are sorted in ascending or descending
order? Why/Why not?
- Do your median, sort, etc. functions need to know that your
data array is dynamic?

This assignment is (Level 1.5).

### Options

Add (Level 1) to allow the user to repeat
the median calculations with another file as long as they would so desire.
(This option is worth levels because the repetition of actions on a file
brings in a new wrinkle above/beyond your typical yes/no loop.
*smile*)

In fact, if you do this, you can make your program a little better by
not reallocating the data array on every new file — only when you
actually need more space. If you already have room for the number of
items you see in the next file, why delete and reallocate? Just use the
necessary portion of the array you already have. To do this will add
another (Level 1)
to this lab.