A function accepts scores from 0 through 100 inclusive. Which testing strategy is most likely to reveal an error caused by using < instead of <=?
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.
Which two outcomes should a robust test for invalid input verify? Select all that apply.
- A
The invalid input is detected.
- B
The program produces an ordinary result anyway.
- C
The program does not silently produce a misleading result.
- D
The test uses only valid inputs.
What technical term names a defect in a program?
Complete each definition. A states what must be true before an algorithm begins. A states what must be true when it finishes.
True or false: Testing can reveal that a program fails, but debugging is the process used to investigate and correct the cause.
- A
True
- B
False
After fixing a defect, why should the team keep a regression test for it?
- A
It replaces all normal test cases.
- B
It measures only memory usage.
- C
It would fail if the same bug returned.
- D
It guarantees that no future bugs are possible.
Which two statements accurately describe reasoning about algorithm correctness? Select all that apply.
- A
A loop invariant remains true before and after each loop iteration.
- B
A few successful examples prove correctness for every permitted input.
- C
Correctness applies only to the most common input category.
- D
Correctness requires the required result for every input satisfying the stated conditions.
What is the two-word term for a property that remains true before and after each loop iteration?
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?
- A
O(n)
- B
O(log n)
- C
O(n²)
- D
O(1)
The slow duplicate-checking function compares pairs of items using two nested loops. What is its worst-case time complexity?
- A
O(n²)
- B
O(n)
- C
O(log n)
- D
O(1)
True or false: Replacing the nested-loop duplicate check with a set usually improves the time complexity to O(n), but requires O(n) additional memory.
- A
True
- B
False
Consider this function:
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.
Complete the documentation requirement: Binary search requires the input values to be in nondecreasing order.
In the complete problem-solving workflow, what should a programmer do first when approaching a new programming problem?
- A
Clarify the specification.
- B
Choose a faster data structure immediately.
- C
Document the final solution.
- D
Run the full test set before defining expected behavior.
A score is valid from 0 through 100 inclusive. Which test set best applies boundary-value testing?
- A
Only scores from 1 through 99, because endpoint values are unusual
- B
Scores just below, at, and just above both valid boundaries
- C
Only randomly selected scores between 0 and 100
- D
Only invalid scores below 0
True or false: If an algorithm passes several carefully chosen examples, those examples alone prove that the algorithm is correct for every allowed input.
- A
True
- B
False
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?
- A
Change
count = 0tocount = 1 - B
Change the condition to
values[i] >= 0 - C
Start the loop at index 0 or iterate directly over the values
- D
Return
len(values)after the loop
In a linear search, what is the name of the property that remains true before and after each iteration?
An algorithm uses two nested loops, and each loop may process all n items in a list. What is the usual worst-case running time?
- A
O(n)
- B
O(n2)
- C
O(logn)
- D
O(1)
What asymptotic time complexity describes a direct calculation whose amount of work does not depend on the input size n? Enter the constant-time complexity in the form O(1).
Related study packs and tools
02 — Information and Representation
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
08 — Discrete Mathematics for Computer Science
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.