{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

finalspring2005

finalspring2005 - NAME NET ID page 1 Final CS100J...

Info icon This 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)
Image of page 1

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

View Full Document Right 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 of Pascal’s triangle. Its specification is given below.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern