After planning an algorithm (e.g., writing pseudocode or a flow), the recommended way to verify correctness before coding is to desk-check the algorithm step by step using sample data.
-
AAnalyze the algorithm
-
BCode the algorithm
-
CDesk-check the algorithm
-
DEvaluate and modify (if necessary) the program.
-
ENone of the above
Answer
Correct Answer: Desk-check the algorithm
Explanation
Introduction / Context:Early error detection is far cheaper than post-implementation fixes. Before coding, designers validate logic by walking through the algorithm manually with representative inputs. This process—desk-checking—exposes logic gaps, boundary errors, and missing cases without the overhead of compiling and running code.
Given Data / Assumptions:
- An algorithm has been planned (pseudocode/flowchart/structured English).
- Test inputs and expected behaviors can be enumerated.
- The goal is to validate logic, not implementation syntax.
Concept / Approach:Desk-checking simulates execution by hand: track variable values, branch decisions, loops, and outputs across steps. It is especially effective for boundary conditions (min/max, empty lists, zero/negative values) and complex decision trees, preventing many coding-time defects.
Step-by-Step Solution:Prepare a set of test cases including normal, edge, and error inputs.Trace each pseudocode step, recording intermediate values.Compare reached outputs with expected results; adjust the algorithm if mismatches appear.
Verification / Alternative check:Teams often combine peer reviews with desk-checks; discrepancies found at this stage drastically reduce later debugging effort, confirming the method’s effectiveness.
Why Other Options Are Wrong:“Analyze the algorithm” is vague and overlaps but does not specify the concrete verification action. Coding first (B) risks embedding logic errors. Option D concerns program evaluation after coding, which is later than necessary. Option E is wrong because desk-checking is the established practice.
Common Pitfalls:Skipping edge cases; not documenting traces; using only “happy path” inputs. Always include extremes and invalid cases in desk-checks.
Final Answer:Desk-check the algorithm