Algorithms Quality Control & Assurance 3 — Questions and Answers
Question 1: What is 'boundary value analysis' used for in algorithm testing?
- Measuring execution time at scale
- Testing inputs at the edges of valid ranges (Correct answer)
- Analyzing memory allocation patterns
- Verifying output formatting
Correct answer: Testing inputs at the edges of valid ranges
Boundary value analysis tests values at and just beyond the limits of input domains, where bugs are most commonly found.
Question 2: Which approach verifies that an algorithm produces the same result when applied multiple times to the same input?
- Concurrency testing
- Idempotency testing (Correct answer)
- Stress testing
- Integration testing
Correct answer: Idempotency testing
Idempotency testing confirms that repeated invocations with identical inputs yield identical outputs, which is critical for functions that must be safely retried.
Question 3: What does 'test-driven development' (TDD) require developers to do first?
- Write documentation
- Write a failing test before writing code (Correct answer)
- Deploy to staging
- Perform code review
Correct answer: Write a failing test before writing code
TDD mandates writing a failing test that defines desired behavior before any production code is written, ensuring code is purpose-built to pass the test.
Question 4: In fuzz testing, what is the primary goal?
- Measuring average-case performance
- Feeding malformed or random inputs to discover crashes and vulnerabilities (Correct answer)
- Ensuring UI consistency
- Validating database schemas
Correct answer: Feeding malformed or random inputs to discover crashes and vulnerabilities
Fuzzing bombards an algorithm with unexpected, malformed, or random inputs to uncover crashes, exceptions, or security vulnerabilities.
Question 5: What is a 'mock object' used for in unit testing?
- Simulating real dependencies so the unit under test is isolated (Correct answer)
- Measuring code execution speed
- Generating synthetic performance logs
- Replacing the compiler for faster builds
Correct answer: Simulating real dependencies so the unit under test is isolated
Mock objects simulate the behavior of real dependencies (databases, APIs) so that the unit being tested can be verified in isolation.
Question 6: Which type of analysis detects bugs by examining source code without executing it?
- Dynamic analysis
- Regression analysis
- Static analysis (Correct answer)
- Mutation analysis
Correct answer: Static analysis
Static analysis tools inspect source code at rest—without running it—to find potential bugs, style violations, or security flaws.
Question 7: What does 'equivalence partitioning' divide in test case design?
- The test team into specialized groups
- The input domain into classes expected to behave the same way (Correct answer)
- The codebase by module ownership
- Test execution into parallel threads
Correct answer: The input domain into classes expected to behave the same way
Equivalence partitioning groups inputs into classes where all members are expected to be treated identically, allowing one representative test per class.
What is 'boundary value analysis' used for in algorithm testing?