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.*

1
Computer Science Foundation Exam
May 3, 2000
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

2
(1, 20%)
Given the following array of numbers and procedure, answer the questions below.
Assume that the global array
X[1.
.n]
is correctly declared and contains the values shown. (So
n=8.) Assume that all division(/) is integer division. So, for example, 17/3 evaluates to 5.
Array X
00000000
Position
12345678
procedure ArrayOperation(i, j: integer)
mid, k : integer;
mid
←
(i + j)/2;
for k
←
itojdo
if(kMOD2=0) then
X[k]
←
X[k] + i
else
X[k]
←
X[k] + j
endif
endfor
if (mid > i) then
ArrayOperation(i, mid);
ArrayOperation(mid + 1, j);
endif
endprocedure
a)
(8 pts) Show the array
X
after the procedure call ArrayOperation(1,8) has executed?
Array X
1
431
652
2
1
1
2
4
1
3
Position
b)
(6 pts) Consider the case where each element of the array X is equal to m, where m is a
positive integer. Now consider executing the procedure ArrayOperation(1,8). What will the
sum of the elements of the array X be, in terms of m, after the procedure call?
Here, the values in the array will be m+14, m+3, m+16, m+5, m+22, m+11, m+24, and
m+13. These add up to 8m+108.

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

Ask a homework question
- tutors are online