Skip to content

Interpolation search

finding

Level 2 of 3

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 interpolation search's own run on the numbers shown.

choose one

question 1

Interpolation search looks for 35 in 8, 17, 21, 35, 43, 57, 88, 91, 96. At which place does its first guess land?

81721354357889196
the answer, and why

the answer is C

The line from 8 to 96 meets 35 at place 3.5. Rounded down, that is place 3, which holds 21.

if you chose another

  • 35 stands at place 4, but the guess is the crossing rounded down, 3.
  • That needs a far bigger last number, making the line climb steeply.
  • Place 9 holds 96, the biggest. Only 96 is guessed there first.

new numbersthe test page's numbers

question 2

How many looks does interpolation search take to find 14 in 7, 14, 17, 19, 20, 92?

71417192092
the answer, and why

the answer is B

92 makes the line climb steeply, so its guesses land at places 1, 2, the last holding 14.

if you chose another

  • One look holds on a row in equal steps. Here 92 makes the line climb steeply.
  • 5 is the most for 6 numbers, n−1n - 1. It is 20, the number before 92, that costs 5.
  • That is binary search's count, its middles 17, 7, 14.

new numbersthe test page's numbers

question 3

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

the answer, and why

the answer is B

Interpolation search takes no look for 23, 33, 43, 53, 63, 73; 85, the fewest of the four.

if you chose another

  • Interpolation search takes 5 looks for this one, more than 0.
  • Interpolation search takes 1 look for this one, more than 0.
  • Interpolation search takes 1 look for this one, more than 0.

new numbersthe test page's numbers