Trace, diagnose and repair algorithms
Trace in execution order
Record values after the statement or iteration named in the question. Carry unchanged values forward. Do not jump directly to the final answer: a trace table records the route taken.

Use a counterexample to find the fault
A greatest-value algorithm initialised with zero appears to work for positive data. The smallest counterexample is a single negative value. Known: the answer must be a member of the data. Therefore initialise from the first item, then compare remaining items.
DECLARE Best, Value : INTEGER
Best ← -8
Value ← -2
IF Value > Best THEN
Best ← Value
ENDIF
OUTPUT Best

Common mistakes
- Filling in only the final values. The table must show each change in the order it happens.
- Updating a variable in the wrong row: a value changes on the line that assigns it, not at the next
OUTPUT. - Fixing the line but not giving the cause. "Changed 0 to Data[1]" earns less than "0 is larger than every negative value, so it was never replaced".
- Testing only the counterexample after a fix. Rerun a normal case as well, so the fix has not broken it.
Distinguish error types
A syntax error breaks the language's structure; a runtime error occurs during execution, such as an out-of-bounds index; a logic error produces the wrong result despite running. After repairing a fault, test the counterexample and a normal case. Explain the cause, not just the changed line.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
Best starts at 8. Process values 5, 7, 2, replacing Best only when a value is smaller. Give Best after each value.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
The starter finds the largest of NumberOfValues values but wrongly outputs zero for all-negative data. Correct it. NumberOfValues is 1 to 5.
출력을 보려면 '실행'을 클릭하세요.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
The program executes without crashing but skips the last array item because its loop ends at NumberOfValues - 1. Is this a syntax, runtime or logic error? Enter one word.
Explain your choice of data structure and loop. Identify one boundary case and predict its result. For a subroutine, explain what is returned or changed in the caller.
이 브라우저의 이번 세션에 저장되었습니다. 교사나 본인이 직접 검토하십시오; 이 설명은 자동으로 채점되지 않습니다.
해당 설명을 다음 기준에 따라 검토하십시오.
- My types and data structure match the data and the question.
- I justified the loop and checked its first and last iterations.
- Initial values and rejected operations preserve the intended state.
- My test includes input, purpose and expected result.
- I distinguished returning a value from printing and changing caller state.