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 48 in 3, 9, 48, 49, 61, 68, 70, 75, 88. At which place does its first guess land?

3948496168707588
the answer, and why

the answer is B

The line from 3 to 88 meets 48 at place 5.2. Rounded down, that is place 5, which holds 61.

if you chose another

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

new numbersthe test page's numbers

question 2

How many looks does interpolation search take to find 7 in 5, 7, 8, 9, 12, 91?

57891291
the answer, and why

the answer is C

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

if you chose another

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

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 D

Interpolation search takes no look for 30, 35, 40, 45, 50, 55; 81, the fewest of the four.

if you chose another

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

new numbersthe test page's numbers