CS 1101: Questions to Help Fill in Templates


If you are able to write down the templates, but then get stuck figuring out what to do next, try asking yourself the following questions:

  1. What do I need to know about the first of the list or the current person?

    For example, if we are counting blue-eyed people, you will need to know if the person has blue eyes. If we are gathering names of CDs by a given artist, you will need to know whether the CD is written by that artist. Figure out what you need, and write down the code.

  2. Is what I need to know a question? If so, insert a cond.

    "Does the person have blue eyes" is a question, so we'll need a cond. In contrast, "the number of copies in stock for this CD" is not a question, so the cond might not be necessary.

  3. What kind of data is the output? A number, boolean, list, etc?

    You can find this by looking at the contract and test cases.

  4. What operator is appropriate for the output?

After this, all that remains is to pull the pieces together.