3 ms·
The dictionary words have a fixed, known upper bound to their length. It's a fixed size dictionary. The dictionary lookup can be considered O(1) on this basis a
by jameshart 4y ago
The dictionary words have a fixed, known upper bound to their length. It's a fixed size dictionary. The dictionary lookup can be considered O(1) on this basis alone.
But then, that means that my candidate string can only be a maximum of twice the length of the longest dictionary word, so the entire process is O(1).
For realistic English words, we're talking about a typical candidate string of length, what, 20 maybe? I need to do somewhere between 19-38 dictionary lookups of 1-19-letter strings to test every splitting of such a word. Why are we even doing big-O analysis here?
Only when you start looking at arbitrarily long strings to see if they are word sequences does this analysis even make sense.