Vote O(n)

correct me if I’m wrong, but O(n) would be the fastest since the comparisons(time) is directly proportional to word.length(). Unless I completely missed something.

so in order of time complexity(least to most complex): O(n) – O(n log n) – O(n^2)

1 Like

It is correct that O(n) is faster (grows more slowly forever) than O(n log n) and O(n^2).

I think the question was, however, what is the best order possible for an implementation of IsIsogram() in the BullCowGame program.

How can you determine that case (i.e., what is the best-possible big-O for this specific situation)?

Bonus: Can you think of a reason that there is an even better big-O in this specific case? Hint: can n grow indefinitely and if not, what might the big-O be?

Privacy & Terms