Linear Search · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Start at the front, stop at the match

Computing · Programming · ages 15-16
Name ______________________   Date ____________
  1. Hunting 45 in 3, 37, 45, 57, 93 and 120, how many checks run before it stops?

    Answer: ______________

  2. Where does a linear search begin checking?

    • At the middle
    • At the front
    • At the end
  3. Linear search still works when the data is jumbled.

    Circle one:   True   False

  4. A name hunt across 30 names misses at every slot. How many checks ran?

    Answer: ______________

  5. Hunting 99 in the same six-item list, what comes back?

    • -1
    • 0
    • 6
  6. On a nonempty list, when does the best case strike?

    • When the target sits last
    • When the list is empty
    • When the target is first
  7. A 600-item list roughly doubles a 300-item list. What happens to worst-case checks?

    • They stay exactly equal
    • They halve at once
    • They roughly double too
  8. A friend claims you must sort before a linear search. What is wrong?

    • Sorting is harmful to every search
    • Sorting is needless, since each item is asked in turn
    • Sorting deletes the target
LightMySky · lightmysky.comW1-mt_32LwZIhSiB-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Start at the front, stop at the match W1-mt_32LwZIhSiB-s1

  1. 3 · Two misses then a match make three checks.
  2. At the front · The hunt opens at the first item and walks forward.
  3. True · It asks each item in turn, so order never matters.
  4. 30 · The worst case checks each of the 30 names once.
  5. -1 · No item matches, so all six checks run and absence is reported.
  6. When the target is first · On a nonempty list, one check is the fewest a hunt can take.
  7. They roughly double too · Worst-case checks track list size in a straight line.
  8. Sorting is needless, since each item is asked in turn · Order never matters here, so sorting buys nothing.
Worksheet · LightMySky