Motivation for a Different Implementation
Suppose instead of grading in the range 0..100, we were to grade in the range 0..100,000, but there are still only 250 students in the class.
// Let histogram be represented by an NatMultiset.
NatMultiset hist = new NatMultiset(100000,250);
would lead to an array of length 100,001.
Shortcomings:
- Large amount of space
- Space utilization is very sparse
- The multiplicity “read-out” takes on the order of a 100,001 steps to look at each element of the array.
The implementation of class NatMultiset can be changed without affecting the client code.