Motivating Example
In many applications, we need to maintain a list of natural numbers, where each natural number may occur more than once.
Such a list is called a “multi-set” of natural numbers.
For example, the set of grades obtained on an exam is such a multi-set.
Specification of class NatMultiset
//Constructor for NatMultiset
public NatMultiset(
int maxValue,
int maxElements
)
// Insert item into multiset.
public void insert(int item)
// Is item in multiset?
public boolean isElement(int item)
// Delete item from multiset.
public void delete(int item)
// Multiplicity of item in multiset.
public int multiplicity(int item)