{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# CS1080601a - Computer Science Foundation Exam August 6 2001...

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

Computer Science Foundation Exam August 6, 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

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

View Full Document
1 (1, 20%) Given the following array of integers and algorithm, answer the questions below. Assume that the global array A[1..n] is correctly declared and contains the values shown. Array A 1 4 2 5 8 6 position 1 2 3 4 5 6 algorithm P1 x, y, i, j, k : integer i ° 1 j ° 6 loop k ° i x ° A[i] y ° A[j] loop exitif (k > j) if(A[k] > x) then x ° A[k] endif if(A[k] < y) then y ° A[k] endif k ° k + 1 endloop A[i] ° x - y A[j] ° 2 * y i ° i + 1 j ° j - 1 exitif (i > j) endloop endalgorithm a) Show the array A after the algorithm has completed execution (2pts each)?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}