CS 210 Assignment 2
Material provided: source file "ST.java" on web
(to do a test run: > javac ST.java > java ST ST.java )
1. Using the array mechanisms we've been discussing, expand this program so that it keeps track of all the symbols seen by the scanner. Keep them in an ordered collection. Keep track of how many times each symbol is seen.
At the end, print out the symbols (in order) along with how often they've appeared.
hint: this may need a helper class to hold each item and its count.
hint2: that class can provide a "compareTo" function
2. Now sort the material you've collected, so you can print it out the most frequently occurring items first.
(This should be a neutral sort: items with the same frequency should stay in order)
hint: insertion sort would be just fine for this job.