Finalspring2005 - NAME NET ID page 1 Final CS100J 12:00-2:30 Barton Hall East 13 May 2005 The results of this final will be posted on CMS as soon

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
NAME _____________________________________ NET ID ______________________ page 1 Final CS100J 12:00-2:30 Barton Hall East 13 May 2005 The results of this final will be posted on CMS as soon as it is graded, hopefully this evening. Grades for the course may be available Saturday, but it may be Monday. Please submit all regrade requests, using CMS where pos- sible, BEFORE 6PM TONIGHT. You have 2.5 hours to complete the questions in this exam, which are numbered 0. .8. Please glance through the whole exam before starting. The exam is worth 100 points. Question 0 (1 point). Print your name and net id at the top of each page. Please make them legible. Question 1 (12 points). Loop. Write a loop (and its ini- tialization) that stores the second largest number in int ar- ray b in variable big2 . The precondition, invariant, and postcondition are given. You must use the given invariant. // precondition: values in b are all different and b.length 2. // invariant: big1 is the largest int in b[0. .k], // big2 is the second largest int in b[0. .k], and // 0 < k < b.length while ( ) { } //postcondition: big1 is the largest int in b[0. .] and // big2 is the second largest int in b[0. .] Question 0. _________ (out of 01) Question 1. _________ (out of 12) Question 2. _________ (out of 12) Question 3. _________ (out of 12) Question 4. _________ (out of 14) Question 5. _________ (out of 12) Question 6. _________ (out of 10) Question 7. _________ (out of 15) Question 8. _________ (out of 12) Total ___________ (out of 100)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NAME _____________________________________ NET ID ______________________ page 2 Question 2 (12 points). Arrays and methods. The first 5 rows of Pascal’s Triangle are shown to the right. The first row is row 0, the second is row 1, etc. The first and last values in each row are 1. In any row with more than two values, a value that is not 1 is obtained by adding the two entries diagonally above it. For example, in the Pascal Triangle on the right, 2 is the result of adding the two 1s diagonally above it. On the fifth row, each 4 is the result of adding the 1 and 3 (or 3 and 1) diagonally above it. Write a method genPascalTriangle that generates a rectangular array that contains the first n rows
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/01/2008 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Page1 / 10

Finalspring2005 - NAME NET ID page 1 Final CS100J 12:00-2:30 Barton Hall East 13 May 2005 The results of this final will be posted on CMS as soon

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online