The prefix edit distance PED(x, y) is the minimal edit distance between x and any prefix of y, i.e. how many edits the typed query x needs to become a prefix of the word y.
Computation. Fill the same DP table M as for ED, with M[i][j]=ED(x[1..i],y[1..j]). The last row holds M[∣x∣][j]=ED(x,y[1..j]), so
PED(x,y)=0≤j≤∣y∣minM[∣x∣][j],
the minimum of the last row instead of the bottom-right entry. Time O(∣x∣⋅∣y∣).
Column cut-off. To decide PED(x,y)≤δ for a threshold δ, only the first ∣x∣+δ+1 columns (column ε and y[1..j] for j≤∣x∣+δ) are needed:
PED(x,y)≤δ⟹PED(x,y)=PED(x,y[1..∣x∣+δ]).ProofProof of the cut-off (exam WS 21/22, Task 3.3)
Let ∣x∣+δ<∣y∣. For j>∣x∣+δ, property 3 of ED gives ED(x,y[1..j])≥j−∣x∣>δ. Since PED(x,y)≤δ, the minimum of the last row is attained at some j≤∣x∣+δ, i.e. at a prefix of y′:=y[1..∣x∣+δ]. The prefixes of y′ are exactly the prefixes of y of length ≤∣x∣+δ, so PED(x,y)=PED(x,y′).
Not symmetric: in general PED(x,y)=PED(y,x). E.g. PED(br,breisgau)=0, but PED(breisgau,br)=ED(breisgau,br)=6 (every prefix of br is at least 6 characters shorter).
No length bound:PED(x,y)≥∣x∣−∣y∣ does not hold: PED(br,breisgau)=0 but ∣x∣−∣y∣=6.
Padding: left-padding both strings with the same q−1$ keeps PED unchanged; right-padding does not (see Q-Gram > Padding).
PED is the relevance model for fuzzy search-as-you-type: the typed text x is an incomplete, possibly misspelled prefix of the intended word. Large web search engines all offer this; the entity search on wikidata.org does not.
PED=min(last row)=2, attained at y′=freibu. For the test PED≤2, only the columns ε, f, r, e, i, b, u (4+2+1=7) are needed; the entries right of the cut are ≥3.