Test your understanding of investigating algorithms using trace tables with this quiz. Remember that you can try the quiz multiple times to practice and see improvements!
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Complete the trace table for the following algorithm using these inputs:
105,100,25,1024,472
Not every cell requires data
Count = 0 FOR Index = 1 TO 5 Number = INPUT 'Enter a number between 100 and 1000' WHILE Number < 99 OR Number > 1001 DO Number = INPUT 'This is incorrect, please try again' ENDWHILE Num[0] = Number NEXT Index PRINT Index PRINT 'numbers were larger than 500'
Count | Index | Number | Num[0] | OUTPUT |
---|---|---|---|---|
105 | 105 | |||
100 | 100 | |||
25 | ||||
1024 | 1024 | |||
472 | 472 | |||
145 | 145 | numbers were larger than 500 |
Which of these was not a logic error in the previous question?
Complete the trace table for the following algorithm using these inputs:
25,17,13,22,12
Not every cell requires data
Score = 0 Total = 0 FOR Student = 1 TO 5 Score = INPUT “Enter student’s score: “ Total = Total + Score NEXT Student Avg = Total / Student OUTPUT ”The average score was ”, Total
Score | Total | Student | Avg | OUTPUT |
---|---|---|---|---|
Identify the logic error in the previous algorithm and rewrite that line of code below to correct it.
Algorithm:
Score = 0 Total = 0 FOR Student = 1 TO 5 Score = INPUT “Enter student’s score: “ Total = Total + Score NEXT Student Avg = Total / Student OUTPUT ”The average score was ”, Total
Complete the trace table for the following algorithm using these inputs:
25,17,13,22,12
Not every cell requires data
LowNum = 1000 HighNum = 0 FOR Count = 1 TO 5 Num = INPUT “Enter number: “ IF Num < LowNum THEN LowNum = Num IF Num > HighNum THEN HighNum = Num NEXT Count OUTPUT LowNum
Num | LowNum | HighNum | Count |
---|---|---|---|
1000 | 0 | 1 | |
Complete the trace table for the following algorithm using these inputs:
5,12,7,6,11,7,5
Not every cell requires data
Count = 0 Arr = [0,0,0,0,0] WHILE Count < 5 DO Num = INPUT “Enter number: “ IF Num < 5 OR Num > 10 THEN OUTPUT “Error” ELSE Arr[Count] = Num Count = Count + 1 END IF END WHILE
Count | Arr | Num | Output |
---|---|---|---|
0 | [0,0,0,0,0] | 5 | |
[ , , , , ] | 12 | ||
[ , , , , ] | 7 | ||
[ , , , , ] | 6 | ||
[ , , , , ] | 11 | ||
[ , , , , ] | 7 | ||
[ , , , , ] | 5 | ||
4 | [ , , , , ] |