SUNY Geneseo Department of Computer Science
CSci 240, Spring 2007
Prof. Doug Baldwin
Due Monday, January 22
Solve each of the following problems.
Recipes are a favorite non-programming example of algorithms. Here is a simple recipe/algorithm for making a hot (or at least warm) fudge sundae:
What are the preconditions for carrying out this algorithm? What are the postconditions?
Text exercise 2.10
Suppose you are given an array, A, containing n numbers. The array's indices range from 0 to n-1. You are supposed to find the largest number in the array. This problem can be more precisely defined by saying that you are to establish the postcondition that "i is an integer such that 0 ≤ i ≤ n-1 and for all integers j such that 0 ≤ j ≤ n-1, A[i] ≥ A[j]."
What, if anything, are the preconditions for establishing this postcondition?
What, if anything, does the postcondition suggest about the design of an algorithm to solve the problem?
I will grade this exercise in a face-to-face meeting with you. Make an appointment to meet with me at some time convenient for you, as long as that time is before the end of the due date above. Meetings only need to be 15 minutes long. You can make an appointment by signing up on the copy of my schedule on the bulletin board outside my office. Please bring written answers to each of the problems to the meeting.