COMP 200 Elements of Computer Science &
COMP 130 Elements of Algorithms and Computation
Spring 2012

Practice for Exam 1

The following problems are typical of those that will be on the exam. In addition to answering these questions, you should also review the course's online notes and the solutions to the two assignments. We have also made a study guide.

The following is a formula for computing compound interest: A = P(1+r/n)n·t, where,

Write a Python function that returns A when given the other values.

Complete the following function that takes a list of numbers [x0, …] and a number n. It returns a list that is [x0n, …].

To compute the maximum element in a non-empty list, we could just use the Python built-in function max. But, how would we define this function ourselves? Complete the following function myMax, which returns the largest element in its input list. You cannot use the built-in function max. You should not sort the list.

Complete the following function that returns the number of positive elements in a list.

Describe what it means to decompose a problem. Why do we do it?

COMP 130 only: Explain the benefits of the full functional decomposition of the second-order predator-prey model plus starvation effects, where the system was ultimately broken down to a representation using small functions to calculate Ψ, Φ, partial derivatives, and starvation effects.