Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 755

The edit distance (also: Levenshtein distance) between two strings measures the number of insertions and deletions it takes to convert one string to another.

1 vote

Insert-only Levenshtein distance

Your problem appears to be: Given strings $S,T$, determines whether $S$ appears as a subsequence of $T$. There are several ways you could approach this. One way is to use dynamic programming and …
D.W.'s user avatar
  • 166k
1 vote
Accepted

hamming distance of bloom filters

Let $S,T$ be two sets of size $n$. Suppose we hash each to a $m$-bit Bloom filter, using $k$ hash functions; let $x_S$ be the $m$-bit vector corresponding to $S$, and $x_T$ the $m$-bit vector corresp …
D.W.'s user avatar
  • 166k
3 votes
Accepted

Efficient algorithm for edit distance for short sequences

One approach is to build a Levenshtein automaton for the fixed string (see, e.g., here). Given a string $x$ and a distance $D$, you can build a DFA that recognizes all strings that are at distance $\ …
D.W.'s user avatar
  • 166k
4 votes
Accepted

Usual distances on DFAs (Deterministic Finite Automata)?

There are many possible distance metrics, and without any criteria, we have no basis to choose. Here are two plausible ones. Let $L_1,L_2$ be the languages of the two DFAs. Let $L$ be the symmetric …
D.W.'s user avatar
  • 166k
0 votes
Accepted

Length of an Edit Script and the Number of Deletions

This is a straightforward consequence of the fact that the edit script only contains insert and delete operations. It follows from a little bit of basic arithmetic -- it's nothing especially deep. C …
D.W.'s user avatar
  • 166k
3 votes

Uniformly sample $x,y\in\{0,1\}^n$ with Levenstein distance $k$

There are two considerations: running time, and correctness. Running time: When $k < (n-1)/\lg(4n)$, heuristically I expect the running time of your algorithm to be fine and I'd guess you won't experi …
D.W.'s user avatar
  • 166k
4 votes
Accepted

Find member of CFL that is Levenshtein-closest to non-member string

Yes. This can be done, using Levenshtein automata. Let $S_k = \{y \in \{0,1\}^* : d(x,y) \le k)\}$. Then the set $S_k$ is regular, and one can construct a finite-state automaton for it, called a Le …
D.W.'s user avatar
  • 166k
6 votes
Accepted

Find all pairs of strings in a set with Levenshtein distance < d

There's a "trick" you can use that might potentially speed up your algorithm a little: shingling. No guarantees that it'll necessarily help in your particular case, though. Lemma. If the edit distan …
D.W.'s user avatar
  • 166k
1 vote

Semi-local Levenshtein distance

If you want the minimum number of single-character changes (insert, delete, substitute) that transforms the shorter string $S$ into some length-$m$ substring of $T$, then this can be done in $O(nm)$ t …
D.W.'s user avatar
  • 166k
3 votes

How fast can we identifiy almost-duplicates in a list of strings?

Comparing two strings Algorithms for computing the Levenshtein edit distance between a pair of strings can be found in the Wikipedia page on the edit distance. As that page explains, the running tim …
D.W.'s user avatar
  • 166k
0 votes

calculating the string similarity of an optimal alignment

I think you should be able to adapt the standard dynamic programming algorithm to this, with a minor modification: you simply treat deletions at the beginning and end of s2 as costing 0.
D.W.'s user avatar
  • 166k