levo

Algorithms and Programs

Standard algorithms: sorting, searching and compression

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

Overview

How a bubble sort puts a list into order, how an insertion sort puts a list into order and one advantage of an insertion sort over a bubble sort.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

State the number of comparisons made by the first pass of a bubble sort on a list of 10 items.

Key term

Describe how a linear search finds a value.

Key term

State what must be true of a list before a binary search can be used on it.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Describe how a bubble sort puts a list into order.

    Model answer

    A bubble sort compares each adjacent pair in turn and swaps them if they are the wrong way round, repeating these passes until a whole pass makes no swap, with the largest value reaching the end after the first pass.

  2. 2

    How does a bubble sort detect that the list is already in order?

    Model answer

    It records whether any swap was made during a pass, and a pass that makes no swap at all shows every adjacent pair is in order so the sort can stop.

  3. 3

    State the number of comparisons made by the first pass of a bubble sort on a list of 10 items.

    Model answer

    The first pass makes 9 comparisons, because it compares each of the 10 items with the one after it.

  4. 4

    Describe how an insertion sort puts a list into order.

    Model answer

    An insertion sort takes each item in turn from the unsorted part and moves it back past every larger item until it sits in its correct place among those already sorted.

  5. 5

    State one advantage of an insertion sort over a bubble sort.

    Model answer

    An insertion sort does far less work on a list that is already nearly in order, because each item usually needs no movement at all.

  6. 6

    Describe how a linear search finds a value.

    Model answer

    A linear search examines each item from the beginning in turn, comparing it with the value wanted, and stops when it finds a match or reaches the end of the list.

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 Algorithms and Programs, 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.