this is just brute force:

count = 0
for i in range(0, len(A)):
    for j in range(i+1, len(A)):
        if A[i] > A[j]:
            count += 1

Time complexity = O(n**2)
Anil


On Sun, Jun 27, 2010 at 9:59 AM, sharad kumar <[email protected]>wrote:

>  Give an unsorted array find count of pairs of numbers[a,b] where a > b and
> b comes after a in the array.
>
> Eg. {8,3,6,10,5}
>
> the count of such numbers is 5. i.e. (8,3), (8,6), (8,5), (6,5) and (10,5)
>
>
>  --
> 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