Free Practice Quiz Question List

8 Testing, Debugging, and Algorithmic Efficiency Online Quiz Questions

Use this free practice quiz with 20 questions to review 8 Testing, Debugging, and Algorithmic Efficiency, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

A function accepts scores from 0 through 100 inclusive. Which testing strategy is most likely to reveal an error caused by using < instead of <=?

  1. A

    Use only the most common valid input.

  2. B

    Test values at and around the input limit.

  3. C

    Test only inputs that produce an error.

  4. D

    Avoid testing the exact boundary because it is predictable.

02
Choose all
1 point

Which two outcomes should a robust test for invalid input verify? Select all that apply.

  1. A

    The invalid input is detected.

  2. B

    The program produces an ordinary result anyway.

  3. C

    The program does not silently produce a misleading result.

  4. D

    The test uses only valid inputs.

03
Written response
1 point

What technical term names a defect in a program?

04
Fill in the blank
1 point

Complete each definition. A states what must be true before an algorithm begins. A states what must be true when it finishes.

05
True or false
1 point

True or false: Testing can reveal that a program fails, but debugging is the process used to investigate and correct the cause.

  1. A

    True

  2. B

    False

06
Choose one
1 point

After fixing a defect, why should the team keep a regression test for it?

  1. A

    It replaces all normal test cases.

  2. B

    It measures only memory usage.

  3. C

    It would fail if the same bug returned.

  4. D

    It guarantees that no future bugs are possible.

07
Choose all
1 point

Which two statements accurately describe reasoning about algorithm correctness? Select all that apply.

  1. A

    A loop invariant remains true before and after each loop iteration.

  2. B

    A few successful examples prove correctness for every permitted input.

  3. C

    Correctness applies only to the most common input category.

  4. D

    Correctness requires the required result for every input satisfying the stated conditions.

08
Written response
1 point

What is the two-word term for a property that remains true before and after each loop iteration?

09
Choose one
1 point

A binary search examines a sorted list by repeatedly halving the remaining search space. What is its typical running-time growth in terms of the list length n?

  1. A

    O(n)

  2. B

    O(log n)

  3. C

    O(n²)

  4. D

    O(1)

10
Choose one
1 point

The slow duplicate-checking function compares pairs of items using two nested loops. What is its worst-case time complexity?

  1. A

    O(n²)

  2. B

    O(n)

  3. C

    O(log n)

  4. D

    O(1)

11
True or false
1 point

True or false: Replacing the nested-loop duplicate check with a set usually improves the time complexity to O(n)O(n), but requires O(n)O(n) additional memory.

  1. A

    True

  2. B

    False

12
Open ended
1 point

Consider this function:

def count_positive(values):\texttt{def count\_positive(values):}
 count = 0\texttt{ count = 0}
 for i in range(1, len(values)):\texttt{ for i in range(1, len(values)):\texttt{}}
 if values[i] > 0:\texttt{ if values[i] > 0:\texttt{}}
 count += 1\texttt{ count += 1}
 return count\texttt{ return count}

Explain why it gives an incorrect result for some valid inputs, identify a minimal revealing test case, and describe a suitable correction. Include how the revealing test should be used after the fix.

13
Fill in the blank
1 point

Complete the documentation requirement: Binary search requires the input values to be in nondecreasing order.

14
Choose one
1 point

In the complete problem-solving workflow, what should a programmer do first when approaching a new programming problem?

  1. A

    Clarify the specification.

  2. B

    Choose a faster data structure immediately.

  3. C

    Document the final solution.

  4. D

    Run the full test set before defining expected behavior.

15
Choose one
1 point

A score is valid from 0 through 100 inclusive. Which test set best applies boundary-value testing?

  1. A

    Only scores from 1 through 99, because endpoint values are unusual

  2. B

    Scores just below, at, and just above both valid boundaries

  3. C

    Only randomly selected scores between 0 and 100

  4. D

    Only invalid scores below 0

16
True or false
1 point

True or false: If an algorithm passes several carefully chosen examples, those examples alone prove that the algorithm is correct for every allowed input.

  1. A

    True

  2. B

    False

17
Choose one
1 point

A function is intended to count positive values, but it uses for i in range(1, len(values)). On input [4, -1, 2], it returns 1 instead of 2. What is the most likely cause of the failure?

  1. A

    Change count = 0 to count = 1

  2. B

    Change the condition to values[i] >= 0

  3. C

    Start the loop at index 0 or iterate directly over the values

  4. D

    Return len(values) after the loop

18
Written response
1 point

In a linear search, what is the name of the property that remains true before and after each iteration?

19
Choose one
1 point

An algorithm uses two nested loops, and each loop may process all nn items in a list. What is the usual worst-case running time?

  1. A

    O(n)O(n)

  2. B

    O(n2)O(n^2)

  3. C

    O(log⁡n)O(\log n)

  4. D

    O(1)O(1)

20
Written response
1 point

What asymptotic time complexity describes a direct calculation whose amount of work does not depend on the input size nn? Enter the constant-time complexity in the form O(1)O(1).