Archive for 12 May 2013

Edit distance algorithm

This little algorithm is one of the coolest things I learned from the programming lectures with Dr Bryan Duggan. Essentially this algorithm shows how much one word needs to be edited to change into another word. It is very useful for writing a spellchecker, or a music recognition app. Below is a C# implementation of the algorithm:

the getEditDistance() method returns 0 if both words are equal, 1 of one letter needs to be changed, etc.