Difficulty: Medium
Correct Answer: Columns for inputs, outputs, and key processing variables (all of the above)
Explanation:
Introduction / Context:
Desk checking (manual dry run) helps validate algorithm logic before coding. A well-designed trace table shows how inputs transform through processing steps to become outputs, exposing logic and boundary errors early.
Given Data / Assumptions:
Concept / Approach:
To fully validate behavior, capture the entire data path. Inputs establish initial conditions, processing variables reveal state transitions, and outputs confirm final results. Omitting any of these can hide defects such as off-by-one errors, mishandled edge cases, or incorrect updates.
Step-by-Step Solution:
1) List inputs: these seed the run (e.g., array values, N, thresholds).2) Identify processing variables: counters (i), indices, sums (total), decision flags (found), temporary holders (temp).3) Specify outputs: final values, messages, returned objects.4) Create columns for each and simulate each algorithm step, recording transitions row by row.
Verification / Alternative check:
Try boundary cases (empty list, single element, maximum size) and ensure the trace table exposes expected transitions and final outputs. Compare to intended algorithm invariants to confirm correctness.
Why Other Options Are Wrong:
Inputs only or outputs only omit essential visibility. Excluding processing variables hides the logic that produces results, making defect detection difficult.
Common Pitfalls:
Not updating the table at each step; skipping state variables; failing to test boundary inputs. These reduce the value of the desk check.
Final Answer:
Include columns for inputs, outputs, and key processing variables.
Discussion & Comments