Hello,
- For O(n^2) the number of comparisons you would have to do for a six-letter word would be 15.
- For O(n) the number of comparisons you would have to do is 26+n, which in this case is 6, so 32 because you have to compare the guess letters to the entire alphabet.
- For O(n log n), where n = 6, the number of comparisons would be 4.66 or about 5.
Clearly, O(n log n) is better because you have to do fewer comparisons. Of course, this is only because n is such a small number and will remain that way for the entire playthrough. Fortunately, we have already coded measures in place to stop guess from being longer than 6 letters.
Hopefully, my understanding is correct…
Thanks,
Enrico