K-12 CS Teacher Professional Development Workshop
1.) Consider the following list.
• Assembly language
• Block-based programming language
• Logic gate
• Machine language
Which of the following arranges the list in order from highest level of abstraction to lowest level of abstraction?
A. Block-based programming language, assembly language, machine language, logic gate
B. Block-based programming language, machine language, assembly language, logic gate
C. Block-based programming language, machine language, logic gate, assembly language
D. Machine language, block-based programming language, assembly language, logic gate
Option A is correct. Of the entries in the list, block-based programming language has the highest level of abstraction, logic gate has the lowest level of abstraction, and the other two entries are in between. Machine language is closer to hardware than is assembly language, so assembly language has a higher level of abstraction than does machine language.
2.) Consider the following pseudocode Boolean expression, where age and height are two properly declared and initialized integer variables.
( age > 10 ) and ( height > 36 )
Which of the following is an equivalent Boolean expression?
A. not ( ( age < 10 ) and ( height < 36 ) )
B. not ( ( age ≤ 10 ) and ( height ≤ 36 ) )
C. not ( ( age < 10 ) or ( height < 36 ) )
D. not ( ( age ≤ 10 ) or ( height ≤ 36 ) )
Option D is correct. The Boolean expression ( age > 10 ) and ( height > 36 ) is true exactly when both age is greater than 10 and height is greater than 36. The same Boolean expression is false exactly either when age is less than or equal to 10 or when height is less than or equal to 36, which is the argument of not () in option D. Another approach to solve this question is to use Boolean logic rules. According to one of De Morgan’s laws, if p and q represent Boolean variables, the Boolean expression p and q is equivalent to the Boolean expression not ( not ( p ) or not ( q )). If p represents the Boolean expression age > 10 and if q represents the Boolean expression height > 36, then not ( p ) represents age ≤ 10 and not ( q ) represents height ≤ 36.
3.) Consider the following pseudocode segment with integer variables, which is intended to determine the largest value among variables a, b, and c, and to store that value in variable max. The code segment does not work as intended.
max ← -1
if ( a > b )
if ( a > c )
max ← a
end if
else
if ( b > c )
max ← b
else
max ← c
end if
end if
Which of the following test cases can be used to demonstrate that the code segment does not work as intended?
A. a ← 20 b ← 15 c ← 15
B. a ← 20 b ← 15 c ← 25
C. a ← 20 b ← 25 c ← 25
D. a ← 20 b ← 25 c ← 30
Option B is correct. Since 20 is greater than 15, the outer if condition evaluates to true and then the condition a > c is evaluated. Since 20 is not greater than 25, the condition a > c evaluates to false and max is not updated. The result is that the value of max at the end of the code segment is -1 instead of 25.