CS1050301a - Computer Science Foundation Exam May 3 2001...

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

View Full Document Right Arrow Icon
Computer Science Foundation Exam May 3, 2001 Section I A No Calculators! Name: _______________________________ SSN: ________________________________ In this section of the exam, there are three (3) problems. You must do all of them. The weight of each problem in this section is indicated with the problem. The algorithms in this exam are written in a combination of pseudocode and programming language notation. Partial credit can not be given unless all work is shown. As always, be complete, yet concise, and above all be neat , credit can not be given when your results are unreadable. KEY
Image of page 1

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

View Full Document Right Arrow Icon
(1, 20%) Given the following array of integers and algorithm, answer the questions below. Assume that the global array X[1..n] is correctly declared and contains the values shown. Array X 3 2 1 2 3 4 position 1 2 3 4 5 6 algorithm P1 a, b, i, j, k : integer i ß 1 j ß 6 loop if (X[i] >= X[j]) then k ß i + 1 a ß 0 loop exitif (k > 6) a ß a + X[k] k ß k + 1 endloop X[i] ß a i ß i + 1 else k ß j - 1 b ß 0 loop exitif (k < 1) b ß b + X[k] k ß k - 1 endloop X[j] ß b j ß j - 1 endif exitif (i = j) endloop endalgorithm a) Show the array X after the procedure has completed execution (2pts each)?
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