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 77 in 18, 35, 53, 55, 59, 70, 71, 77, 97. At which place does its first guess land?

183553555970717797
the answer, and why

the answer is C

The line from 18 to 97 meets 77 at place 6.97. Rounded down, that is place 6, which holds 70.

if you chose another

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

new numbersthe test page's numbers

question 2

How many looks does interpolation search take to find 11 in 6, 11, 13, 14, 19, 97?

61113141997
the answer, and why

the answer is A

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

if you chose another

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

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 C

Interpolation search takes no look for 4, 19, 34, 49, 64, 79; 81, the fewest of the four.

if you chose another

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

new numbersthe test page's numbers