actually the problem is to make BST construction in O(nlogn)...
we need rotations  which changes the structure so you wont be able to
distinguish between elements right to a particular elements, elements left
to it . ( in original array )..

On Tue, Jul 13, 2010 at 12:52 AM, Tech Id <[email protected]> wrote:

> Initialise all elements of ar_low with 0
>
> for (int i=0; i<n-1; i++) {
>    for (int j=i+1; j<n-1; j++) {
>        if (ar[j] <= ar[i])
>            ar_low[i]++ ;
>    }
> }
>
> O(n^2)
>
>
> For O(nlogn), create a BST - O(nlogn)
> Traverse the tree, counting children on the left side of each node and
> putting it ar_low - O(n)
>
> --
> 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]<algogeeks%[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