Which of the following pairs BEST distinguishes a procedure from an event handler?
Loading test…
Loading test…
12 questions
Which of the following pairs BEST distinguishes a procedure from an event handler?
Which of the following problems has a REASONABLE (polynomial-time) algorithm, and which is considered to have only UNREASONABLE (exponential-time) algorithms for large inputs?
Which of the following lists contains the elements in the correct order after a linear (sequential) search of the list [3, 7, 1, 9, 4] for the value 9?
A procedure double(n) returns n * 2. What is the value returned by double(double(3))?
What is displayed when the following pseudocode runs?
nums ← [10, 20, 30, 40, 50]
total ← 0
FOR EACH n IN nums
{
total ← total + n
}
DISPLAY total
Which of the following Boolean expressions evaluates to true?
A list scores ← [85, 92, 78, 90, 65] is passed to the procedure below. What value does mystery(scores) return?
PROCEDURE mystery(list)
{
best ← list[1]
FOR EACH item IN list
{
IF (item > best)
{
best ← item
}
}
RETURN best
}
What is displayed when the following pseudocode runs?
result ← 1
REPEAT 5 TIMES
{
result ← result * 2
}
DISPLAY result
A delivery company needs to find a route that visits 30 cities and returns home with the lowest total distance. An exact algorithm guaranteed to find the optimal route would take an impractically long time. Which approach is MOST appropriate?
What is displayed when the following pseudocode runs?
x ← 10
IF (x > 5)
{
IF (x > 12)
{
DISPLAY "big"
}
ELSE
{
DISPLAY "medium"
}
}
ELSE
{
DISPLAY "small"
}
A programmer needs to compute the area of three rectangles with different dimensions and display each area. Which approach BEST demonstrates procedural abstraction?
A student writes the following procedure header:
PROCEDURE addNumbers(a, b)
Which statement BEST describes what a and b are?