aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 6.1Debugging
Back to Computer Science HL Topics
6.1.46 min read

Debugging (Computer Science HL)

IB Computer Science · Unit 6

IB exam ready

Study like the top scorers do

Access a smart study planner, AI tutor, and exam vault — everything you need to hit your target grade.

Start Free

Contents

  1. 1Finding the difference between expected and actual
  2. 2The four techniques
  3. 3A method for narrowing down
  4. 4Exam-style question
The big idea: A program that runs but gives the wrong answer has a logic error, and the computer cannot tell you where it is.

Debugging is narrowing down where the values first stop being what you expected.
Three kinds of error: Syntax — the code will not run at all; the editor usually points straight at it.

Run-time — it stops partway, with a message naming the problem.

Logic — it runs perfectly and produces the wrong answer. This is the one that needs debugging.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
1

Trace table — on paper

Work through the code by hand, writing every variable after every step.

Slow, and needs no tools at all — which is why it is what the exam asks for. It also finds errors in logic that no amount of running will reveal.

2

Print statements

Add an output line that shows a value at a chosen point, labelled with what it is.

Crude but effective, and works anywhere. Label every one, or you will not know which line produced which number.

3

Breakpoints

Mark a line and the program pauses there, letting you inspect every variable at that moment.

Better than prints when you do not yet know which value is wrong, because you can look at all of them at once.

4

Step-by-step execution

From a breakpoint, run one line at a time and watch the values change.

This is what finds a loop that runs one time too many, or a branch taken when it should not have been.

The trace table is the exam technique: Breakpoints need software. A trace table needs a pen.

So when a question gives you code and asks what is wrong, the intended method is nearly always to trace it by hand.

Get feedback like a real examiner

Submit your answers and get instant feedback — what you did well, what's missing, and exactly what to write to score full marks.

Try AI Tutor FreeYour first topic is free to keep • No credit card required
1

1 — Say what you expected

Write down the answer the program should give for one specific input.

Without that, you cannot tell which value first went wrong — only that something did.

2

2 — Find the first wrong value

Check the variables at a point roughly halfway through. If they are right, the fault is later; if wrong, it is earlier.

Halving the search each time finds it in a few checks, however long the program.

3

3 — Look at what changes it

Once you know which value first goes wrong, look only at the lines that set it.

That is usually two or three lines out of a hundred.

4

4 — Change one thing, then test

Fix one thing and run the same test again.

Changing several at once means that if it works you do not know why, and if it still fails you have a new set of suspects.

Test the boundary first: Most logic errors show up at the edges: an empty list, a single item, the first and last positions, values that are exactly equal.

If a program is wrong, try the boundary before anything else.

How this is tested — you must trace the code and say WHICH line is wrong, not just that it is. It comes up two ways:

Paper 2 — working with code

  • Identify the error in a program and correct it, 3-5 marks
  • Complete a trace table for faulty code
  • Name a debugging technique and say what it finds

Paper 2 — the algorithmic-thinking question

  • Reason about where a described program goes wrong
  • Explain how you would narrow it down
The classic trap: Rewriting the whole program. The question asks which line is wrong and what it should be — a full rewrite usually loses marks even when the new version works.
IB-style questionIdentify[5 marks]

This should print the largest of a list but prints 0 for a list of negative numbers. Find the error.

largest = 0 for value in numbers: if value > largest: largest = value print(largest)

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic
IB-style questionIdentify[5 marks]

This should print the largest of a list but prints 0 for a list of negative numbers. Find the error.

int largest = 0; for (int value : numbers) { if (value > largest) { largest = value; } } System.out.println(largest);

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Debugging. Write your answer and get instant AI feedback — just like a real IB examiner.

the term debugging. [1 mark]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

6.1.1Variables and data types6.1.2Substrings6.1.3Exception handling6.2.1Static vs dynamic structures
View all Computer Science HL topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Computer Science HL
Previous6.1.3Exception handlingNextStatic vs dynamic structures6.2.1

23 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science HL Topics