Assignment - 1

Problem Definition: Find the maximum of a given set of numbers.

TO DO: Extend the algorithm developed in class for max to find both max and min of the given set in one walk through the numbers.


Assignment - 2

Problem Definition: Find the mean of a given set of numbers.

TO DO: Come up with the specification for the problem above. Give the pseudo code for the algorithm.


Assignment - 3

Write an algorithm that determines the mode of a list of numbers. The mode is the value that occurred most frequently. For example, in

1 2 2 3 3 3 4 5 5 6 6 7 7 7 7 8

the mode is 7 with a frequency of 4. You may assume that:

  1. The values are already sorted into ascending sequence.
  2. The values are input to the algorithm from the keyboard. When a value of -1 is encountered, print the mode and exit the program.
  3. If two or more values occur with equal frequency, the mode is the numerically defined largest value.
The algorithm you develop SHOULD NOT all the data in a list; it should read in only one value at a time and process that value. The output of your algorithm should be the mode and its frequency.