How many cells does the method fill to compare stone and notes?
the answer, and why
the answer is C
5 rows of 5 cells, a row for each letter of stone. The first row and column are written at the start.
if you chose another
AThat counts the first row and column too, which are written at the start, not filled.
BThat is the longest common subsequence, such as t and e.
DThat adds the letters, but each row fills a cell for each letter of notes.
2question 2
How many letters do lemon and melon share in the same order, at most?
the answer, and why
the answer is A
Such as l, o and n, or e, o and n. Could they share 4? Leave one letter out of each word: lemon gives emon, lmon, leon, lemn and lemo, and melon gives elon, mlon, meon, meln and melo. None match.
if you chose another
BThey have the same 5 letters, but not in the same order.
CThat is o and n, the longest run side by side. The letters may have gaps, such as e, o and n.
D0 is only for words with no letter in common.
3question 3
Which pair makes the method fill the most cells?
the answer, and why
the answer is D
5 times 5, which is 25.
if you chose another
A3 times 4, which is 12.
BEqual words still fill every cell, but 4 times 4 is 16.
C1 times 6, which is 6.
4question 4
The last letters of a cell's two starts differ. What does the method write in the cell?
the answer, and why
the answer is A
Shared letters cannot use both last letters, so the cell leaves one out and keeps the larger. Question 4 of the learn page's section 4 shows that this is the most.
DThat leaves out both letters, and may miss a shared one.
pen and paper
5question 5about 8 minutes
Run the method by hand on stop and tops.
Fill the table.
How many letters do they share in order, and how many cells did you fill?
Read back the shared letters.
a hint
The first row and column hold 0.
a worked answer
The table is drawn below. The last cell says 3 letters, and you fill 16 cells, 4 rows of 4. Reading back: left from the last cell, then up and to the left three times, taking p, o and t. Read in order, that is t, o and p.
A diff tool compares two files of 20,000 lines each with this method, each line taken as one letter.
How many cells does it fill?
How long does that take at a billion cells a second?
How many numbers does the table hold, and how many do two rows hold?
a hint
Questions 1 to 3 of the learn page's section 4 count all three.
a worked answer
20,000 times 20,000, which is 400,000,000 cells, about 0.4 seconds. The table holds 20,001 times 20,001, which is 400,040,001 numbers, but two rows hold only 40,002.
Question 1: how many cells, , does the method fill on two words of letters, from 1 up?8 of 8 shown
1the move: a row for each letter
the line:
order
-
r
ra
ram
-
given
given
given
given
a
given
1
2
3
ar
given
4
5
6
arm
given
7
8
9
Arm and ram, each cell numbered in the order it is filled, row by row. Given cells are written first, not counted. 3 rows of 3, 9 cells.
why it is allowed: Each letter of the first word has a row, and each row fills one cell for each letter of the second. Crate and cart fill 5 times 4, 20 cells.
2the move: both of n letters
the line:
why it is allowed: Here the first word has letters too, so is . For 3, 3 times 3, which is 9.
guess it, then
3the move: write it shorter
the line:
why it is allowed: times is written , read squared. For 3, 9.
guess it, then
4the move: a ceiling
the line:
why it is allowed: By line 3, as a number is at most itself.
guess it, then
5the move: read the bound
the line:
why it is allowed: means at most a fixed multiple of , from some on, and reads is in. By line 4, is at most 1 times , from 1 up.
guess it, then
6the move: a floor
the line:
why it is allowed: By line 3, as a number is at least itself.
guess it, then
7the move: read the bound
the line:
why it is allowed: means at least a fixed multiple of , above 0, from some on. By line 6, is at least 1 times , from 1 up.
guess it, then
8the move: both together
the line:
why it is allowed: Lines 5 and 7 bound by the same growth. means both.
guess it, then
try it with a small : at , line 2 gives , which you can work out by hand