Search a cyclically sorted array with duplicates: small optimization

#1

In the case when A.get(mid) == A.get(right) you say that we cannot eliminate either side. We actually can: if A.get(left) != A.get(middle) then there is no way the breaking point is on the right and we recurse only left.

Only when all 3 elements are equal, we cannot decide where to go and have to cover both.

0 Likes

#2

Hey @damluar,

Thanks for the idea, and it is really cool observation!

0 Likes