# HG changeset patch # User Luke Plant # Date 1293213684 0 # Node ID 71eca4eec96c57467143feec86de013dbb6fccf3 # Parent 4012e7dde247d422cc75669947e8091d132e1975 Added comment about a more efficient way of using the word tree. diff --git a/phone2word.hs b/phone2word.hs --- a/phone2word.hs +++ b/phone2word.hs @@ -185,8 +185,19 @@ So the algorithm is: - find all the 'word logs' - - necessarily an O(n^2) algorithm, assuming we can check a - string of digits in constant time + - looking up a single sequence of digits in the wordTree + is O(1), since the wordTree has a fixed depth defined by + the dictionary. + + - here we use an O(n^2) algorithm to find sub-sequences + of the original digits, so it is O(n^2) overall. + + - we could use an algorithm that looks up a sequence of + digits *and* all the prefixes of that sequence in a + single pass through the wordTree, which would allow + us to find all the words in the digit sequence in O(n) + time. But it isn't the limiting factor. + - add in all necessary 'digit logs' - depends on the number and spacing of word logs - find all routes across the river