levo

Recursion, Sorting and Searching

Searching and shortest-path algorithms

  • 3 things to know
  • A2 Unit 3
Start revising · £5/month

Overview

Recall questions on the complexity of linear and binary search and why, the comparisons needed on a million items, when linear beats binary, why binary needs an array, what Dijkstra's algorithm records and why it can finalise the smallest distance, negative weights, a worked shortest route, and A*.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

How does the A* algorithm differ from Dijkstra's algorithm?

Key term

State the complexity of a binary search and explain why it has that complexity.

Key term

State the greatest number of comparisons a binary search makes on a sorted list of 1,000,000 items.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    State the complexity of a linear search and explain why it has that complexity.

    Model answer

    A linear search is O(n), because in the worst case every one of the n items has to be examined before the answer is known.

  2. 2

    State the complexity of a binary search and explain why it has that complexity.

    Model answer

    A binary search is O(log n), because every comparison discards half of the items still under consideration.

  3. 3

    State the greatest number of comparisons a binary search makes on a sorted list of 1,000,000 items.

    Model answer

    2¹⁹ is 524,288 and 2²⁰ is 1,048,576, so at most 20 comparisons are needed.

  4. 4

    How many further comparisons does a binary search need when the list it is given is doubled in length?

    Model answer

    Just one more, because that single extra comparison halves the doubled list back to its original length.

  5. 5

    Under what conditions does a linear search beat a binary search?

    Model answer

    A linear search wins on a very short list, on a list that is not in order, and wherever the cost of sorting the list first would outweigh the saving.

  6. 6

    Why must a binary search be given a list held in an array rather than in a linked list?

    Model answer

    A binary search has to jump straight to the midpoint, and only an array allows a position to be reached by calculation rather than by following pointers from the start.

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.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

Cram the night before, weakest topic first

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

Fetch, , execute.
decodecompilestore

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.

A bit is a single binary digit.
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 Recursion, Sorting and Searching, 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.