We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Not quite. All possible combinations of 2 letters is k*(k-1)/2, for an alphabet of size k. Since the alphabet in this case is a fixed size, i.e. k = 26, all possible combinations of 2 letters can be checked in 325 iterations for any input of size n, which is O(1). I agree that if the alphabet was variable size, this would be O(n^2).
Two Characters
You are viewing a single comment's thread. Return to all comments →
Not quite. All possible combinations of 2 letters is k*(k-1)/2, for an alphabet of size k. Since the alphabet in this case is a fixed size, i.e. k = 26, all possible combinations of 2 letters can be checked in 325 iterations for any input of size n, which is O(1). I agree that if the alphabet was variable size, this would be O(n^2).