Skip to content

Edit distance

planning ahead

Level 2 of 3

Also called Levenshtein distance and Wagner-Fischer algorithm.

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

choose one

question 1

How many cells does the method fill to turn mouse into beach?

the answer, and why

the answer is C

5 rows of 5 cells, a row for each letter of mouse. The first row and column are written at the start.

if you chose another

  • That counts the first row and column too, which are written at the start, not filled.
  • That is the fewest edits, not the cells.
  • That adds the letters, but each row fills a cell for each letter of beach.

new numbersthe test page's numbers

question 2

How few edits turn lots into lost?

the answer, and why

the answer is A

Keep l, o, replace t with s and s with t. Swapping two letters is not one edit, so it costs 2.

if you chose another

  • That counts a swap as one edit, which it is not.
  • That replaces every letter, but l, o can stay.
  • 0 is only for equal words. These have the same letters in a different order.

new numbersthe test page's numbers

question 3

Which pair makes the method fill the most cells?

the answer, and why

the answer is B

house, rain fills 20 cells, a row for each letter of the first word and a cell for each letter of the second, the most of the four.

if you chose another

  • That pair fills 3 cells, fewer than 20.
  • That pair fills 16 cells, fewer than 20.
  • That pair fills 12 cells, fewer than 20.

new numbersthe test page's numbers