levo

Big O Notation and Algorithm Efficiency

Comparing algorithms that do the same task

  • 3 things to know
  • Component 1

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

KDW to HAT.
decryptsencryptscompresses

Blank Blitz makes facts automatic

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

AThe two are not the same.
BOpen source refers to the availability of the code.
CMuch open source software is free of charge.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

Backup means the copy of the data.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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