Com S 100J Introduction to Computer Programming Grade: letter or S/U Fall 2003
4 credits Newsgroup: cornell.class.cs100j Instructor: David Gries

Quiz 04 Array algorithms
Home
About email
Academic Excellence Workshop
Academic integrity
Announcements
DrJava
Exams & grades
FAQs
Handouts, general
    Assignments
    Labs
    Quizzes
Links
Staff info
Syllabus
Texts
Times & places
 
Email Gries

 

This quiz will be given on 06 November!!!

Reason for quizzes.

A course like CS100 uses a lot of terminology and introduces many new concepts. Typically, the terminology and concepts are used from the day they are introduced onward. If you don't learn them soon after they are introduced, you can't understand later lectures and material. So, each quiz alerts you to what is important for you to learn at that time (and forces you, hopefully, to learn it). We hope that you don't only superficially learn it but grok it. (If you don't know what grok means, bring up ProgramLive (the CD), open the glossary, and look at the entry for grok.

For quiz 04, you have to be able to write down these three algorithms, each given as a loop with initialization.

  • Linear search. See Sec. 8.5.1.

  • Finding the minimum. See Sec. 8.5.2.

  • Binary search. See Sec. 8.5 3.

1. Learn the specification of the method. Practice writing it!

2. Learn the invariant for the loop. Often, it need not be memorized because it is a simple modification of the postcondition of the algorithm. Practice writing the invariant!

The preconditon, postcondition, and invariant can be given either in math and English or as a picture.

3. Practice developing the code, using the four loopy questions.

• Note: the text gives each of these algorithms as a method. The only return statement in each method is at the very end, after the answer has been calculated. There are NO return statements in the loops, and we don't expect you to write them in the loop.