Dynamic Programming on Two Sequences · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Filling the grid between two strings

Computing · Algorithms & Data Structures · ages 20-21
Name ______________________   Date ____________
  1. Where do you read the final answer?

    • The top-left cell
    • The far corner cell
    • Outside the table
  2. What do the rows and columns of the table stand for?

    • Prefixes of each string
    • Random numbers
    • The alphabet in order
  3. What does walking back through the table give you?

    • The alignment that produced the answer
    • A new pair of strings
    • The time of day
  4. A cell pairs A with U, a mismatch costing 1. What does that choice mean?

    • Delete both strings
    • Substitute one letter for the other
    • Stop the whole table
  5. Turn CAT into CUT with unit costs. Give the edit distance.

    Answer: ______________

  6. A delete move skips one character from the side string.

    Circle one:   True   False

  7. Two different tracebacks can give the same corner distance.

    Circle one:   True   False

  8. The corner reads 1 for CAT and CUT, but a friend lists two edits. What is wrong?

    • Nothing, corners lie
    • CAT and CUT share no letters
    • The traceback shows one substitution, so one edit suffices
LightMySky · lightmysky.comW1-mt_uNUgHcKKQN-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Filling the grid between two strings W1-mt_uNUgHcKKQN-s1

  1. The far corner cell · The corner holds the value for the full pair of strings.
  2. Prefixes of each string · Each row steps through one string, each column through the other.
  3. The alignment that produced the answer · The traceback names the actual edits behind the number.
  4. Substitute one letter for the other · Pairing two different last characters is a substitution.
  5. 1 · C pairs, T pairs, and one middle substitution makes 1.
  6. True · Each move type skips or pairs exactly as defined.
  7. True · Tied cells offer equal-cost paths to the same answer.
  8. The traceback shows one substitution, so one edit suffices · Pair, swap, pair is a single edit achieving the corner value.
Worksheet · LightMySky