Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Algorithms
  • Dynamic programming
  • Medium

What is the edit distance between "kitten" and "sitting", if insertion, deletion and substitution each cost 1?

Algorithm Design

Pick an option to check your answer.

Fill the standard edit-distance table, or find three edits that are clearly needed:

  1. kitten → sitten (substitute k with s)
  2. sitten → sittin (substitute e with i)
  3. sittin → sitting (insert g)

Two edits cannot work: the lengths differ (6 against 7), so at least one insertion is needed, and the first and fifth letters both differ. The DP table confirms the minimum is 3.

Why not the others

  • 22 misses one of the three required changes; the strings differ in length and in two letters.
  • 44 is the cost of a valid but non-optimal sequence of edits.
  • 55 counts mismatches position by position without allowing an insertion to realign the strings.

Report an error

GATE CS · Algorithms · Algorithm Design