Free Practice Quiz Question List

10. Integrated Problem-Solving Practice Online Quiz Questions

Use this free practice quiz with 20 questions to review 10. Integrated Problem-Solving Practice, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

In the temperature_counts function, which category should contain a temperature value of 32?

  1. A

    below freezing

  2. B

    comfortable

  3. C

    hot

  4. D

    invalid

02
Choose one
1 point

According to summarize_scores, what does summarize_scores([6, 10, 14]) return?

  1. A

    (3, 20, 10)

  2. B

    (2, 30, 15)

  3. C

    (3, 30, 10)

  4. D

    (3, 30, 30)

03
Choose one
1 point

Which precondition is necessary for the binary-search implementation in the material to be correct?

  1. A

    The values must be sorted according to the comparison ordering.

  2. B

    The list must contain only distinct values.

  3. C

    The list must contain at least one element.

  4. D

    The target must be larger than the first value.

04
Choose all
1 point

Which two design decisions match the frequencies function described in the material? Select all correct choices.

  1. A

    Use a mapping from each item to its count.

  2. B

    Require the input list to be sorted first.

  3. C

    Return an empty mapping when the input is empty.

  4. D

    Maintain two parallel lists for items and counts.

05
Choose all
1 point

Which two statements correctly describe the binary-search implementation in the material? Select all correct choices.

  1. A

    Its worst-case time is O(n).

  2. B

    Its worst-case time is O(log n).

  3. C

    Its extra space is O(1).

  4. D

    It requires an additional set containing every input value.

06
True or false
1 point

True or false: In an algorithm, an invariant is a statement that remains true at a specified point during execution.

  1. A

    True

  2. B

    False

07
True or false
1 point

True or false: If an algorithm is decidable, it must also be efficient for typical inputs.

  1. A

    True

  2. B

    False

08
Written response
1 point

What single-word growth descriptor describes the worst-case running time of the linear_search function?

09
Written response
1 point

The sorted list is [1, 2, 2, 2, 5]. What integer index should first_occurrence(values, 2) return? Enter the zero-based index only.

10
Fill in the blank
1 point

Complete the corrected average function's return expression: return total / .

11
Fill in the blank
1 point

Complete the loop body so find_first_even progresses when the current value is odd: if values[index] % 2 == 0: return values[index] followed by .

12
Open ended
1 point

Explain why has_duplicate_fast is generally more efficient than has_duplicate_slow. Compare their time complexity, extra-space usage, and the trade-off involved.

13
Choose one
1 point

What does the provided binary_search([], 4) return?

  1. A

    It raises an index error.

  2. B

    It returns -1 without entering the loop.

  3. C

    It returns 0 because the list has no elements.

  4. D

    It enters an infinite loop.

14
Choose one
1 point

According to the temperature_counts function, how is a temperature of 32 classified?

  1. A

    below freezing

  2. B

    comfortable

  3. C

    hot

  4. D

    invalid input

15
Choose one
1 point

What does summarize_scores([]) return according to the stated design?

  1. A

    (0, 0, 0)

  2. B

    (0, None, None)

  3. C

    (0, 0, None)

  4. D

    ([], 0, None)

16
Written response
1 point

Using the averaging rule in summarize_scores, what is the average of the scores [6, 8, 10]?

17
Written response
1 point

What one-word descriptor characterizes how the worst-case running time of linear search grows with the input size?

18
True or false
1 point

True or false: Binary search is appropriate only when the data is sorted according to the same ordering used by its comparisons.

  1. A

    True

  2. B

    False

19
Choose one
1 point

Why is has_duplicate_fast generally more efficient than has_duplicate_slow for a large list?

  1. A

    It uses no additional memory and guarantees O(1) time.

  2. B

    It uses O(n) time but always uses less memory than the nested-loop method.

  3. C

    It usually reduces expected running time to O(n) by using additional memory.

  4. D

    It sorts the input first, so its worst-case time is O(log n).

20
Choose one
1 point

For the sorted list [1, 2, 2, 2, 5], why does first_occurrence([1, 2, 2, 2, 5], 2) return index 1 rather than index 2 or 3?

  1. A

    It returns immediately at the first matching index.

  2. B

    It records the match and continues searching the left half.

  3. C

    It discards the left half and searches only for a later match.

  4. D

    It changes the list so duplicate values are removed.