i feel do a heapify and then just try an O(n) adjacent element difference on
the resulting one.

On Sat, Aug 6, 2011 at 6:34 PM, Algo Lover <[email protected]> wrote:

> given an UNSORTED real number array x1,x2,...,xn, how to find the max
> distance of two neighbouring numbers in the number axis. Is there any
> method with O(n) time complexity?
> see an example
> given x[]={2.0,1.0,9.0,-3.5}
> then the answer is 7.0, because on the number axis, it is
> -3.5,1.0,2.0,9.0 from left to right.
> distance between two neighbouring numbers are 1-(-3.5),2-1,9-2.
> so the answer is 9-2=7
>
> --
> 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.
>
>

-- 
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