levo

Searching and Shortest-Path Algorithms

Linear search

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

Overview

How a linear search works, main advantage of a linear search and time complexity of a linear search.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What does each of the linear and binary searches assume about order, and when is the linear search right?

Key term

Describe how a linear search works.

Evaluation

What is the main advantage of a linear search?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Describe how a linear search works.

    Model answer

    A linear search examines each item in turn from the start of the list. The search stops when the target is found or the end of the list is reached.

  2. 2

    What is the main advantage of a linear search?

    Model answer

    A linear search needs no ordering of the data, so it works on any list. The algorithm is also very simple to write and to check.

  3. 3

    State the worst case number of comparisons a linear search makes on a list of n items.

    Model answer

    The worst case is n comparisons, which happens when the target is last or absent. A list of twice the length gives twice the worst case.

  4. 4

    How many comparisons does a linear search make on average when the item is present?

    Model answer

    The average is about half the list, or (n + 1) ÷ 2 comparisons. The figure is roughly 100 for a list of 200 items.

  5. 5

    A linear search looks for 23 in the list 8, 15, 4, 23, 42, 7. How many comparisons are made?

    Model answer

    Four comparisons are made because 23 sits in the fourth position. The search stops as soon as the item is found.

  6. 6

    A linear search looks for 30 in the list 8, 15, 4, 23, 42, 7. How many comparisons are made?

    Model answer

    Six comparisons are made because every item must be checked. The search then reports that 30 is not in 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.

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 Searching and Shortest-Path Algorithms, 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.