...
With the Stem and Leaf plot I was wondering how to include the in between 10's values in the stem
...
As I wrote in one of my previous replies: I am more concerned about the characteristics of the stemplot table as there seem to be no consensus.
So if you want to change the characteristics (of the stemplot table) you need to find another approach.
One of them could indeed be as you wrote/suggested.
I would personally try another approach. Having said that, it is just /an/ approach and there are probably many approaches possible that lead to the same result. So take the following with keeping that in mind. I tried to stay as close to something that can be explained and/or implemented in an easy way.
Currently you have split up the textual representation of numbers into lines so that every number has its own line.
I would convert these numbers into integers and store them into a dynamic array of integers.
When these numbers are stored into a dynamic array they can easily be sorted from lowest to highest number (see wiki about sorting for example). That will take care of a few things:
- the lowest number is located at the first entry of the array
- the highest number is located at the last entry of the array
- the numbers are in perfect order for a stemplot table because they are stored and can be processed from low to high
You can then take the lowest number and extract the stem from it, and you can do the same for the highest number (therefor highest stem).
Now that you know the lowest and highest stem you know which (other) stems need to be present in between those two extremes. Ergo you can iterate between those two extremes in order to fill in the missing stems.
You add all those stems (including lowest and highest) to the stemplot table but omit the leaves for now.
Then you can iterate over the dynamic number array again, extract the stem (and leaf), try to locate the stem in the stemplot table and add the leaf just as you did before.
The main difference is that in the way I present things I would prefer a stemplot table that uses integer numbers instead of strings but in theory you can choose either way (conversion between integers and strings are simple to implement).
There is probably a much better, faster and more logical approach possible but the main advantage (I think) for this presented approach is that you are able to split up different parts of the process that I mentioned in different subroutines that can all do one (small) specific part of the process as described.
What do you think yourself ?
PS: This time I did not prepare anything so if anyone else would want to take a stab at it...