aimnova.
DashboardMy LearningPaper MasteryStudy 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
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

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

NotesComputer Science HLTopic 6.4
Unit 6 · Programming · Topic 6.4

IB Computer Science HL — Programming algorithms

Programming algorithms

Higher Level students should use this topic hub as a map: start with the shared sub-topics, then follow the HL-only extensions and exam-skill links where this topic asks for deeper analysis.

Exam technique guidePractice questions

Key concepts in Programming algorithms

Key Idea: Complexity describes how an algorithm's cost grows with the data — not how long it takes on one machine. That is why the growth rate, not the constant factor, decides which algorithm survives at scale.

Paper 1

  • Short definitions and a trace.
  • State, identify, outline — precise terms.

Paper 2

  • Write or correct Python for a scenario — your paper is the Python version, option B.
  • Construct, determine, suggest.

Both

  • Trace tables and justified choices earn method marks even when the final answer slips.

📈 The complexities to know

OrderDoubling the data…Example
O(1)changes nothingArray access by index
O(log n)adds one stepBinary search
O(n)doubles the timeLinear search
O(n log n)a little over doublesThe best a comparison sort can do
O(n²)quadruples the timeBubble and selection sort
3n + 50 is O(n): the constant differs between machines and languages, and at scale the growth rate decides which algorithm wins. A better constant only moves the crossover point.

🔎 The two searches

Linear searchBinary search
Data must beAnythingSorted
CostO(n)O(log n)
1000 itemsUp to 1000 checksAbout 10 comparisons
Best whenUnsorted, searched onceSorted, searched many times
Important: Sorting costs O(n log n) — more than the single linear search it would replace. Binary search wins when the data is already sorted, or when it will be searched many times.

🔃 The two sorts

What distinguishes them

  • Bubble compares adjacent pairs and swaps; each pass floats the largest to the end
  • Selection finds the smallest in the unsorted part and swaps it into place
  • Both are O(n²): 4 + 3 + 2 + 1 comparisons for 5 elements, which is n(n − 1)/2
  • Bubble can stop early if a pass makes no swaps — O(n) on already sorted data
  • Selection makes at most n − 1 swaps, which matters when moving a record is expensive

Practical judgement

  • Better complexity is not always the better choice — on 20 items, simplicity wins
  • Space complexity matters too: running out of memory is a hard failure, not a slow one
  • Caching trades memory for speed — store a result rather than recompute it
  • For real work use the language's own sort: better tested and better optimised

📝 Exam-style questions

IB-style questionDetermine[4 marks]

An algorithm takes 2 seconds on 1000 records and 8 seconds on 2000 records. Determine its likely complexity, and predict the time for 8000 records.

🔒 Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic →
IB-style questionSuggest[3 marks]

A program searches an unsorted list of 500 names once, to answer a single query. A student suggests sorting it first so binary search can be used. Suggest whether this is worthwhile, justifying your answer.

🔒 Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic →

✅ Quick check

Cover the answers.

Doubling the data doubles the time — which complexity? O(n) — linear.

Why does binary search need sorted data? It discards half the range by comparing with the middle value — meaningless if the data is unordered.

Which sort can finish in O(n) on already-sorted data? Bubble sort, if it stops early when a pass makes no swaps.

Why quote the worst case? It is the only one that guarantees the algorithm will never be slower than stated.

Why is 3n + 50 written as O(n)? Constants and lower-order terms differ between machines; at scale the growth rate decides.


Exam tips

  • Read the RATIO: same time = O(1), double = O(n), quadruple = O(n²).
  • Quote the worst case unless the question says otherwise.
  • Binary search needs sorted data — say so every time you name it.
  • Include the cost of sorting when comparing search strategies.
  • n(n − 1)/2 is the comparison count for both O(n²) sorts. Learn it.
  • Better complexity is not always the better choice — small n favours simplicity.

What you'll learn in Topic 6.4

  • 6.4.1 Big O notation
  • 6.4.2 Linear and binary search
  • 6.4.3 Bubble and selection sort
  • 6.4.4 Recursion
  • 6.4.5 Tracing recursion
Suggested study order: Read the notes for each sub-topic below → test yourself with flashcards → attempt practice questions → review exam technique.

Study resources — 6.4 Programming algorithms

6.4.1

Big O notation

Notes
6.4.2

Linear and binary search

Notes
6.4.3

Bubble and selection sort

Notes
6.4.4

Recursion

Notes
6.4.5

Tracing recursion

Notes

Ready to study Programming algorithms?

Get expert practice questions with instant AI feedback, and a study planner tailored to your IB Computer Science HL exam date.

Start studying free

Topic 6.4 Programming algorithms forms a core part of Unit 6: Programming in IB Computer Science HL. Mastering these concepts will strengthen your understanding of connected topics across the syllabus and prepare you for exam questions that require analysis, evaluation, and real-world application.

Previous topic
6.3 Programming constructs
Next topic
6.5 File processing
All Computer Science HL topics
Exam technique

Ready to practice?

Get AI-graded practice questions, mock exams, flashcards, and a personalised study plan — all aligned to your IB syllabus.

Start Studying Free

No credit card required · No time limit