This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

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

Computer Science Foundation Exam
October 22 , 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.
As always, be complete, yet concise, and above all be neat
,
credit can not be given when your results are unreadable.
(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.
Array X
4
5
2
6
3
5
3
1
position
1
2
3
4
5
6
7
8
procedure R(a, b : integer)
j, k, y, z : integer;
y <- 0;
z <- 0;
j <- 1;
k <- b;
while (j <= k) do
if (X[k] < X[j]) then
y <- y + X[k];
X[k] <- X[k] + k;
k <- k - 1;

This
** preview**
has intentionally

else
z <- z + X[j];
X[j] <- X[j] - j;
j <- j + 1;
endif
if (z > y) then
z <- z - 1;
else
y <- y + 1;
endif
endwhile
endprocedure
a)
Show the array
X
after the procedure was called with
R(5, 8)
?
Array X

This is the end of the preview. Sign up
to
access the rest of the document.

Ask a homework question
- tutors are online