levo

Big O Notation and Algorithm Efficiency

Comparing algorithms that do the same task

  • 3 things to know
  • Component 1
Start revising · £5/month

Overview

Two resources Big O is used to compare between algorithms and drawback that comparison hides in the hash table.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What does Big O compare, why is the comparison fair between languages, and should an O(n log n) or an O(n²) algorithm be chosen for a million items?

Key term

State the two resources Big O is used to compare between algorithms.

Key term

Why is Big O a fair way to compare two algorithms written in different languages?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    State the two resources Big O is used to compare between algorithms.

    Model answer

    Big O compares execution time and memory requirement.

  2. 2

    Why is Big O a fair way to compare two algorithms written in different languages?

    Model answer

    Big O measures the algorithm rather than the implementation. The language, compiler and processor affect the constant factor only.

  3. 3

    Two algorithms sort the same list. One is O(n log n) and the other O(n²). Which should be chosen for a list of one million items, and why?

    Model answer

    The O(n log n) algorithm should be chosen. A million items cost it roughly twenty million operations, against a million million for the quadratic one.

  4. 4

    Give one reason a programmer might still choose the algorithm with the worse complexity.

    Model answer

    A simpler algorithm is easier to write correctly and to maintain. On small or nearly sorted data it may also be faster in practice.

  5. 5

    What does Big O fail to tell you about two algorithms in the same class?

    Model answer

    Big O hides the constant factor, so two O(n) algorithms can differ by a factor of ten in real running time.

  6. 6

    Why can the same algorithm have different complexities for time and for space?

    Model answer

    Time and space are separate resources. A quicksort is O(n log n) in time and O(log n) in space, because the recursion stores far less than it processes.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Data Structures: Arrays, Records and Hash Tables
Stacks, Queues, Linked Lists and Trees
Boolean Logic and Simplification
Algorithms, Pseudo-Code and Programming Constructs

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

KDW to HAT.
decryptsencryptscompresses

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Backup means the copy of the data.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Big O Notation and Algorithm Efficiency, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.