📘 Paper 2 · Topic 7: Algorithm Design & Problem Solving
7.3d Algorithm Efficiency
Cambridge IGCSE Computer Science 0478 · ~12 min read · ⭐ Pro

What is Algorithm Efficiency?

The efficiency of an algorithm describes how well it performs as the size of the input (n) grows. An efficient algorithm does more work with fewer comparisons, steps, or memory usage.

At IGCSE level, you compare algorithms by counting the maximum number of comparisons (or steps) for a given n.

Comparing the Four Key Algorithms

AlgorithmTypeMax comparisons (n items)Requires sorted?
Linear searchSearchingnNo
Binary searchSearchinglog₂(n)Yes
Bubble sortSorting~n²/2 (n−1 passes)No
Merge sortSorting~n × log₂(n)No

In practice — concrete examples

nLinear searchBinary searchBubble sortMerge sort
88328~24
16164120~64
1,0001,000~10~500,000~10,000
1,000,0001,000,000~20~5×10¹¹~20,000,000

Choosing the Right Algorithm

The best algorithm to use depends on:

  • Size of data: for small datasets, even an inefficient algorithm is fast enough. For large datasets, efficiency matters greatly.
  • Whether data is sorted: if already sorted, binary search is ideal. If unsorted, sorting first (then binary searching) may be worth it only if you will search many times.
  • How often you search: if searching only once, a linear search may be simpler. If searching many times, sorting first (for binary search) saves time overall.

Sorted vs Unsorted — the tradeoff

Suppose you have 1,000 items and need to find one value:

  • Linear search (unsorted): ~1,000 comparisons
  • Sort first (bubble: ~500,000) then binary search (~10): ~500,010 comparisons total — WORSE!
  • But if you search 1,000 times: linear = 1,000,000 vs sort once then binary × 1,000 = 500,000 + 10,000 = 510,000 — sorting first wins!

Summary Comparison

Linear SearchBinary SearchBubble SortMerge Sort
EfficiencyLow (large n)HighLow (large n)High
Data must be sorted?NoYesNoNo
Extra memory needed?MinimalMinimalMinimal (temp)Yes
Complexity to codeSimpleModerateSimpleComplex
Best forSmall/unsorted dataLarge sorted dataSmall dataLarge data
Exam tip: Cambridge often asks you to "justify your choice of algorithm" — always state WHY (e.g., "binary search is more efficient as it halves the search space on each step, so it needs only log₂(n) comparisons rather than n"). Simply naming an algorithm without justification usually loses marks.
⚠️ Common Mistakes
  • Saying "binary search is better" without explaining WHY (fewer comparisons, halving the search space)
  • Confusing efficiency with speed — efficiency is about how comparisons scale with n, not absolute speed
  • Thinking merge sort always needs fewer comparisons than bubble sort for ALL inputs — for very small n, bubble sort may actually be faster in practice due to lower overhead
Video coming soon
Click slide or press arrow keys to navigate
✍️

Worksheet — Algorithm Efficiency

4 questions · 9 marks

Q1A database has 1,024 records. What is the maximum number of comparisons needed using binary search to find one record? Show your working. [2]
✅ Mark scheme
Maximum comparisons = log₂(1024) = 10 [1]; working: 2¹⁰ = 1024, so 10 halvings are needed [1]
Q2A programmer needs to sort 10,000 items and then search through them 500 times. Justify which combination of algorithms would be most efficient. [3]
✅ Mark scheme
Use merge sort to sort [1]; because for 10,000 items it is more efficient than bubble sort (fewer comparisons) [1]; then use binary search for the 500 searches [1] because binary search on sorted data requires only log₂(10000) ≈ 13 comparisons rather than up to 10,000 for linear search
Q3Explain why binary search cannot be used directly on an unsorted list of 1,000 names. What would need to happen first and what is the trade-off? [3]
✅ Mark scheme
Binary search requires sorted data [1]; the list would need to be sorted first (e.g., using merge sort) [1]; the trade-off is that sorting takes time (extra comparisons) — this is only worthwhile if many searches will be performed on the same data [1]
Q4State one situation where linear search would be preferred over binary search. [1]
✅ Mark scheme
Any one: the data is not sorted and sorting would take too long [1]; the list is very small so efficiency is not a concern [1]; you only need to search once (sorting overhead not justified) [1]
Quiz — Algorithm Efficiency
Q 1 of 7
Score
/ 7
Click to reveal
TermDefinition
🎯

Mini Test — Algorithm Efficiency

10 minutes · mixed marks

← 7.3c Merge Sort Topic 7 Complete! Next: 8.1a Programming Concepts →
🔒
Pro Content
Upgrade to access all lessons.
£7.99/month
or £59/year
Subscribe now →