aug17-99 - Computer Science Foundation Exam August 17, 1999...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Science Foundation Exam August 17, 1999 - CS I section In this section of the exam, there are six (6) problems, some with multiple parts. You are to do all of them. The weight of each problem in this section, is indicated with the problem. The parts of a multi-part problem are equally weighted. The algorithms in this exam are written in a combination of pseudocode and programming language notation. The algorithms that you are asked to produce should use a syntax that is clear and unambiguous. 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 the algorithm below, 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 M(a, b : integer) c, d, i, j : integer; c <- 0; d <- 0; i <- a - 1; j <- c + 1; while (i > j) do if (X[i] >= X[j]) then c <- c + (X[i] - X[j]); j <- j + 1; else c <- c + (X[j] - X[i]); i <- i - 1; endif if (X[i] < b) then X[i] <- X[i] + 1; else X[i] <- X[i] - 1; endif d <- d + X[j]; endwhile endprocedure a) Show the array X after the procedure was called with M(8,4) ? Array X...
View Full Document

Page1 / 8

aug17-99 - Computer Science Foundation Exam August 17, 1999...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online