Skip to content

Longest common subsequence

planning ahead

Level 2 of 3

Also called LCS and Longest common subsequence, by dynamic programming.

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 longest common subsequence's own run on the numbers shown.

choose one

question 1

How many cells does the method fill to compare shape and glass?

the answer, and why

the answer is A

5 rows of 5 cells, a row for each letter of shape. 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 longest common subsequence, not the cells.
  • That adds the letters, but each row fills a cell for each letter of glass.

new numbersthe test page's numbers

question 2

How many letters do cried and cider share in the same order, at most?

the answer, and why

the answer is C

Such as c, i, e, 3 letters in the same order in both. No 4 letters stand in the same order in both.

if you chose another

  • They have the same 5 letters, but not in the same order.
  • That is c, the longest run side by side. The letters may have gaps, such as c, i, e.
  • 0 is only for words with no letter in common.

new numbersthe test page's numbers

question 3

Which pair makes the method fill the most cells?

the answer, and why

the answer is C

blanket, picture fills 49 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 6 cells, fewer than 49.
  • That pair fills 10 cells, fewer than 49.
  • That pair fills 30 cells, fewer than 49.

new numbersthe test page's numbers