CSE 321 Homework 17


In the last closed lab, given a simple application that counted the number of occurrences of letters in a given text input, you created a small application that counted the number of occurrences of words in a given text input. You were also given several maintenance activities.

The closed lab had two main objectives:

  1. To show a couple of examples of a more general, common problem, namely, to compute/store the occurrences/frequencies of items in a data set, and
  2. To give you a small sample of other requirements that may arise in such applications.

The two applications used different data structures to collect and store the data, and some of the maintenance activities may have revealed the need for additional or different components to support some or all of the new functionality. The objective of this homework is for you to outline the design of a new abstract (kernel) component that would be useful in solving a general application involving counting occurrences of (arbitrary) items (including the two problems you dealt with in closed lab). Another example of such an application could be a web site shopping cart, which is used to keep track of the various items the customer is thinking of buying and how many instances of each item.

A simple and non-exhaustive list of the requirements for the new component are the following:

  1. The new component needs to allow the client to count the number of occurrences of arbitrary items;
  2. It should also support easy computation of item frequencies;
  3. It should be possible to iterate over distinct items without having to iterate on each instance of each item (e.g., to print a table of occurrences).

The component does not need to support directly all extra features discussed in the closed lab maintenance activities. For instance, the ability to print the output in sorted order could conceivably be achieved by using a sorting machine.

A new abstract kernel component provides the client view. As you know, that includes

  1. the mathematical model,
  2. the initial value, and
  3. the kernel operations.

In this homework you are still doing a preliminary, exploratory design, so we don't expect a finished, polished product (but it must be well thought out and readable). Here is what you should turn in as your homework:

  1. A description of the abstract value of this new component, i.e., the mathematical model. For now, this can be expressed in informal (but precise) terms, or better yet, with mathematical types such as string, set, tuple, integer, boolean, etc.
  2. The initial value that objects of this new type are expected to have, expressed in terms of the abstract value you chose in your first answer.
  3. A list of kernel operations (names, parameters, and short description of intended behavior). Usually you want to keep this set as small as possible while still providing the needed functionality.