Skip to content

Linear search

finding

Level 1 of 3

Also called Sequential search.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from linear search's own run on the numbers shown.

choose one

question 1

Linear search looks for 61 in 54, 61, 3, 61, 81. At which place does it stop?

546136181
the answer, and why

the answer is C

It looks at each number from place 1 until 61 at place 2, which is the number wanted. It stops there.

if you chose another

  • That is the second 61. The search stops at the first.
  • Place 1 holds 54, which is not 61.
  • Place 5 is reached only when the number is not there, or stands last. Here it stands at place 2.

new numbersthe test page's numbers

question 2

How many looks does linear search take to learn that 1 is not in 85, 40, 28, 59, 93, 37, 32?

85402859933732
the answer, and why

the answer is B

1 is not there, so every one of the 7 numbers is looked at, once each.

if you chose another

  • One look finds a number only when it stands first.
  • That is the average for a number that is there, (7 + 1) over 2.
  • There is no place 8. The search stops after place 7.

new numbersthe test page's numbers

question 3

Which search costs linear search the fewest looks? Each option is a row, then, after the semicolon, the number wanted.

the answer, and why

the answer is C

Linear search takes 1 look for 49, 18, 68, 16, 85; 49, the fewest of the four.

if you chose another

  • Linear search takes 5 looks for this one, more than 1.
  • Linear search takes 3 looks for this one, more than 1.
  • Linear search takes 4 looks for this one, more than 1.

new numbersthe test page's numbers