int InvCount(int arr[], int n)
{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr > arr[j])
count++;
return count;
}
a) O(n)
b) O(n log n)
c) O(n2)
d) O(log n)
What is the time complexity of the following code that determines the number of inversions in an array?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What is the time complexity of the following code that determines the number of inversions in an array?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!