P: 2
|
a) Dry run the following pseudo-code using the test data shown below it. Draw up a table with one column for - EACH variable in the algorithm. [12]
-
Input (P)
-
While P ≠ 0
-
Input (K)
-
T 0
-
For R 1 to K
-
Input (X,Y)
-
If X > Y
-
then T T + 2
-
else If X = Y
-
then T T + 1
-
Endif
-
Endif
-
Endfor
-
Output (P, K, T)
-
Input (P)
-
Endwhile
-
USE DATA 10, 3, 4, 3, 5, 2, 1, 1, 20, 4, 5, 5, 2, 2, 1, 2, 0, 0, 30, 2, 1, 2, 3, 4, 0
-
b) List the outputs that are produced. [3]
| |
Share this Question
Expert 5K+
P: 6,596
|
a) Dry run the following pseudo-code using the test data shown below it. Draw up a table with one column for - EACH variable in the algorithm. [12]
-
Input (P)
-
While P ≠ 0
-
Input (K)
-
T 0
-
For R 1 to K
-
Input (X,Y)
-
If X > Y
-
then T T + 2
-
else If X = Y
-
then T T + 1
-
Endif
-
Endif
-
Endfor
-
Output (P, K, T)
-
Input (P)
-
Endwhile
-
USE DATA 10, 3, 4, 3, 5, 2, 1, 1, 20, 4, 5, 5, 2, 2, 1, 2, 0, 0, 30, 2, 1, 2, 3, 4, 0
-
b) List the outputs that are produced. [3]
That'll depend on the programming language that you are using.
Moving to Misc. Discussions from Member Intro.
| | | | Question stats - viewed: 1962
- replies: 1
- date asked: May 7 '07
|