previous | start | next

Application

Problem: For a text file, find the word that occurs most frequently.

Use a symbol table whose keys are words (String type) and whose value is the frequency of occurrence of each word (Integer type).

  1. Read the file and extract one word k at a time.
  2. Use the get(k) method to either determine that k is in the symbol table or not.
  3. If the word k is not in the symbol table, insert k with the value 1.
  4. If the word k was already in the symbol table, get its value, increment it, and put (k, updated value) back in the symbol table.


previous | start | next