It can't be done in O(log n) unless the array is sorted or there is
some other special property, for example, if all values x are known to
be contiguous, allowing you to use a binary search to find the first
and last location of x.

In the general case it is impossible in O(log n) because you have to
examine at least n/2 elements to reach a conclusion. In some cases you
must examine all n elements.

Don

On Feb 8, 1:45 pm, Prakhar Jain <jprakha...@gmail.com> wrote:
> Hello everyone,
>
> suppose we have an array of size n and a number, say x, and we have to
> determine whether the number x is present in the array more then n/2 times
> or not....?
> can we have an O(log n) algo for determining it......?..pls help...!!!
>
> --
> --
> Prakhar Jain
> IIIT Allahabad
> B.Tech IT 3rd Year
> Mob no: +91 9454992196
> E-mail: rit2009...@iiita.ac.in
>           jprakha...@gmail.com

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

Reply via email to