CS 176, Introduction to Computer Science II

Summer 2001 - Design Test 1


Introduction

Professor Fibonacci is studying the population growth of Australian jackrabbits, which are a non-native species with no natural predators. Prof. Fibonacci has discovered that if s jackrabbits are introduced into an ecosystem, the jackrabbit population grows as follows:

  1. There are s + 1 jackrabbits after the first breeding season.

  2. If there were pi jackrabbits after breeding season i and pi + 1 jackrabbits after breeding season i + 1, then there will be pi + pi + 1 jackrabbits after breeding season i + 2.

For example, starting with

p0 = 5
jackrabbits, after the first breeding season there will be
p1 = 5 + 1 = 6
jackrabbits; after the second breeding season there will be
p2 = p0 + p1 = 5 + 6 = 11
jackrabbits; after the third breeding season there will be
p3 = p1 + p2 = 6 + 11 = 17
jackrabbits and so on.

To aid the research, Prof. Fibonacci would like you, the laboratory computing specialist, to model a jackrabbit ecosystem. The model should be initialized with the integer start, the number of jackrabbits to start, and max, the maximum number of jackrabbits the ecosystem can support (because they have no natural predators, the jackrabbit population grows until they eat all available food). start must be an integer value greater than 0; max must be an integer value greater than or equal to start; you may assume that max - start <= 1000.

The model should support the following operations:

The professor would like to be able to run several versions of the model at the same time to allow for comparative analysis.

And Now, the Design Test

For this design test you should

  1. Describe the data structures you would use to model the jackrabbit ecosystem. For each data structure give the type, its name, and a brief description of its use. Don't forget that the professor will want to run several versions of the model at the same time.

  2. Give the prototypes for each of the procedures associated with the model. Don't forget that the prototypes for seasons and populations must match the specifications given above. You may add any other procedures you feel are necessary to implement the model.

  3. Describe the implementation of each procedure associated with the model. You need not write code; you may describe each step in the implementation with a brief sentence.

    You should describe each implementation in enough detail to show you understand the problem and you have some idea of how to solve it. If you are unsure about your answer, err on the side of providing too much detail rather than too little.


This page last modified on 27 June 2001.