{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# CS1121599 - Computer Science Foundation Exam Section I A No...

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

1 Computer Science Foundation Exam December 15, 1999 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. If you need extra room to do work to be graded then do so on the last page attached to this test. Make sure to clearly label the problem you are working on. As always, be complete, yet concise, and above all be neat , credit can not be given when your results are unreadable.

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

View Full Document
2 (1, 20%) Given the following array of numbers and algorithm, answer the questions below. Assume that the global array X[1. .n] is correctly declared and contains the values shown. Also, assume that n is the length of the array, the / operator performs an integer division, and that the array will always contain distinct values, in general. Array X 37269581 Position 12345678 procedure ArrayOperation() i, j, k, s, t: integer; i ± 0; j ± 0; s ± 0; k ± (1+n)/2; while ((s <> k) AND (i <= n))do // This was a mistake on the actual i ± i+1; // exam. It should have read s ± 1; // ((s <> k) AND (i < n)) j ± 1; // The way it is written there while (j <= n) do // would be an array out of bounds if (X[i] > X[j]) then // error. I’m sorry about that! s ± s+1; endif j ± j+1; endwhile t ± X[i]; X[i] ± X[s]; X[s] ± t; endwhile endprocedure a) (8 pts) Show the array X after the procedure was called? Array X 15396782 Position b) (6 pts) Assuming that n is odd and that the value of i is 1 at the end of a call to the procedure above, what is true about the original value stored in X[1] before the procedure call?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

CS1121599 - Computer Science Foundation Exam Section I A No...

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

View Full Document
Ask a homework question - tutors are online