B[n]=0;
for i=n to 1
{
if(A[i-1]<=A[i])
B[i-1]=B[i];
else
B[i-1]=B[i]+1;
}
O(n) solution.
Correct me if I am wrong.

On Tue, Oct 4, 2011 at 2:07 PM, anshu mishra <anshumishra6...@gmail.com>wrote:

> int count(int x, int tree[], int s, int e, int n)
> {
> tree[n]++;
> if (s==e) return 0;
> int cnt = 0;
> int mid = (s+e)/2;
> if (mid < x)  return tree[2*n+1]+count(x, tree, mid+1, e, 2*n+2);
> else return count(x, tree, s, mid, 2*n+1);
> }
>
> main()
> {
>   for(i=n-1;i>=0; i--)
>   {
>   sol[i] = insert(ar[i], tree, 0, n-1, 0)
>
>   }
> }
>
> --
> 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.
>

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