@Anup: It is O(n). The worst case is a[] =
{1,2,1,2,1,2,1,2,1,2,...,1,2,1,2,1,0} where you are searching for x =
0. It will take n/2 steps. The best case is a[] = {n, n-1, n-2, ...,
1,0}, in which case it will take 1 step.

Dave

On Aug 30, 12:32 am, Anup Ghatage <[email protected]> wrote:
> @tech
> Could you give an example for this?
> If I've understood the question correctly, if we are not allowed duplicates
> in the array the array turns out to be sorted.
> If we are allowed duplicates, do we return the first occurrence ?
>
> @Dave
> What would be the complexity of your solution?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to