Edit Distance Algorithm implementation.