Scholars Gate
Find a TutorOnline Tutoring
GuidesHow It WorksBecome a Tutor
Log inGet Started
All guides
Computer ScienceA-Level 9 min read

Big-O Notation & Algorithm Efficiency

Flip between the growth curves and see why an O(n²) algorithm crawls where an O(n log n) one flies. Big-O notation, made visual.

The ScholarsGate Computer Science Team·Updated 08 Jul 2026

On this page

  • What Big-O measures
  • See it: compare growth rates
  • The common complexity classes
  • Working out an algorithm’s Big-O
  • Common mistakes
  • Practice
  • FAQ

Two programs solve the same problem. One is fine on a million records; the other grinds to a halt on a thousand. Big-O notationis the language that captures that difference — not how fast an algorithm is, but how well it scales.

What Big-O measures

Big-O describes how the amount of work an algorithm does grows as the size of its input, n, grows. It deliberately throws away detail that does not matter for large inputs: constant factors (is each step twice as fast?) and lower-order terms. What is left is the shape of the growth — the thing that decides whether an algorithm survives a big dataset.

So Big-O is not measured in seconds. It answers a sharper question: if I double the input, roughly how much more work is there? An O(n) algorithm does twice as much; an O(n²) algorithm does four times as much.

Big-O is about the slope of the growth, not the height of the curve at any one point.

See it: compare growth rates

The differences between complexity classes are invisible for tiny inputs and overwhelming for large ones. The graph below plots operations against input size n for each class at once, so you can watch the curves fan apart.

Select a class to draw it boldly, and drag the point to read the operations at a chosen n.

InteractiveComparing growth rates
Loading interactive…
Switch between complexity classes; the faint curves show the others for comparison. Drag the point to read operations at input size n.
Text description ↓Hide text description ↑

A graph of operations against input size n for the common Big-O classes. Selecting a class draws it boldly with the others faint behind it, so you can see O(1) stay flat, O(log n) barely rise, O(n) climb steadily, O(n log n) a little faster, and O(n²) and O(2ⁿ) shoot upwards. Dragging the point reads off the number of operations at a given n.

The common complexity classes

A handful of classes cover almost everything you will meet, listed here from best to worst:

  • O(1) — constant. The work is fixed, whatever the input size. Reading array element a[i] by its index takes the same time in a list of ten or ten million.
  • O(log n) — logarithmic. Each step throws away half the remaining data. A binary search of a sorted list finds any item in a handful of steps.
  • O(n) — linear. The work is proportional to the input. A linear search that checks every item once is the classic example.
  • O(n log n) — linearithmic. A little steeper than linear. Merge sort and the other efficient sorts live here.
  • O(n²) — quadratic. Work grows with the square of n. Two nested loops over the same data, or bubble sort, give this.
  • O(2ⁿ) — exponential. Work doubles with each extra input. Some brute-force approaches (trying every subset of n items) blow up like this and become unusable even for modest n.

Working out an algorithm’s Big-O

You rarely need to count operations exactly. Three rules get you the class quickly.

Keep only the fastest-growing term

Drop constants and lower-order terms. A count of 3n² + 5n + 100 operations is simply O(n²): for large n the n² term dwarfs everything else, and the 3 in front does not change the shape of the growth. Big-O keeps only the term that dominates.

Nested loops multiply. A loop over n inside another loop over n runs n × n times — O(n²). Consecutive stages add: a loop over n followed by a separate loop over n is O(n) + O(n), which is still O(n). Finally, Big-O usually describes the worst case— the most work the algorithm could be forced to do — because that is the guarantee that matters.

Common mistakes

Thinking a bigger O is better

Big-O measures cost, so a bigger class is worse, not better. O(n²) grows faster than O(n log n), which grows faster than O(n). When someone “improves” an algorithm they make its Big-O smaller— O(n²) down to O(n log n), say.

Quoting the best case instead of the worst

Almost any search is O(1) if you get lucky and the item is first. That best case is not the headline figure. Big-O normally reports the worst case, because that is the behaviour you must be able to rely on when the input is chosen against you.

Practice

Your turn

An algorithm runs two separate loops over the n items, one after the other, and then a nested double loop over the same n items. What is its overall Big-O?

Show the answer ↓Hide the answer ↑

The two single loops are O(n) + O(n) = O(2n), which simplifies to O(n). The nested double loop is O(n × n) = O(n²). Running the stages in sequence, you add them: O(n) + O(n²). The fastest-growing term wins, so overall it is O(n²).

Where next?

Big-O comes to life when you watch it happen: the sorting algorithms guide runs O(n²) and O(n log n) methods side by side with live operation counts, so you can see these curves play out on a real list.

Key takeaways
  • Big-O describes how an algorithm’s work grows with input size n, ignoring constants and lower-order terms.
  • From best to worst: O(1), O(log n), O(n), O(n log n), O(n²), O(2ⁿ) — a smaller class is faster.
  • Simplify by keeping only the fastest-growing term: 3n² + 5n + 100 → O(n²).
  • Nested loops multiply and consecutive stages add; Big-O usually reports the worst case.
  • A bigger O is worse, not better — and the best case is rarely the figure that matters.

Frequently asked questions

What does Big-O notation mean?+
Big-O notation describes how the running time (or memory) of an algorithm grows as the input size n grows, ignoring constant factors and lower-order terms. O(n) means the work grows in proportion to n; O(n²) means it grows with the square of n.
Why do we ignore constants in Big-O?+
Big-O is about how an algorithm scales, not its exact time on one machine. For large n the highest-order term dominates, so 3n² + 5n + 100 is simply O(n²) — the constants and smaller terms become irrelevant to the growth rate.
Which is better, O(n log n) or O(n²)?+
O(n log n) is better (faster-growing is worse). For n = 1000, O(n log n) is about 10,000 operations while O(n²) is 1,000,000 — a hundredfold difference that only widens as n grows.
What is the worst time complexity?+
Among common classes, O(2ⁿ) (exponential) and O(n!) (factorial) are the worst — they become unusable even for modest inputs. O(1) constant time is the best, followed by O(log n) and O(n).
SC

The ScholarsGate Computer Science Team

Oxbridge & Russell Group computer science tutors

Written and reviewed by ScholarsGate tutors who teach GCSE, A-Level and undergraduate computer science. Every explainer is checked against the AQA and OCR specifications.

Keep exploring

A-Level Computer Science tutorsSorting algorithms, visualisedAll interactive guides

Want a tutor to walk you through it?

Book a DBS-checked A-Level Computer Science tutor for a 1-on-1 lesson — online or in person.

Find a A-Level Computer Science tutor
Scholars GateTutoring & Learning

ScholarsGate (Scholars Gate) is a premium UK tutoring marketplace connecting ambitious students with expert tutors across every subject, level, and admissions pathway.

hello@scholarsgate.co.uk
+44 7544 736438
Bath, United Kingdom

Platform

  • Find a Tutor
  • Online Tutoring
  • How It Works
  • Become a Tutor
  • Interactive Guides
  • Blog
  • FAQ

Subjects

  • Mathematics & Computing
  • Natural Sciences
  • Humanities
  • Languages
  • All Subjects

Admissions

  • Medicine & UCAT
  • Maths (TMUA, STEP)
  • Law & LNAT
  • Statements & Interviews
  • All Admissions
4.9/5 average tutor rating
All tutors DBS verified
Secure payments via Stripe
500+ expert tutors

© 2026 ScholarsGate Ltd. All rights reserved.

Privacy PolicyTerms of ServiceCookie PolicySafeguarding