#include <bits/stdc++.h>
using namespace std;
void convert(int a[], int n)
{
vector <pair<int, int> > vec;
for (int i = 0; i < n; i++)
vec.push_back(make_pair(a, i));
sort(vec.begin(), vec.end());
for (int i=0; i<n; i++)
a[vec.second] = i;
}
void printArr(int a[], int n)
{
for (int i=0; i<n; i++)
cout << a << " ";
}
int main()
{
int arr[] = {10,8,2,5,7};
int n = sizeof(arr)/sizeof(arr[0]);
convert(arr , n);
printArr(arr, n);
return 0;
}
a) O(n)
b) O(n log n)
c) O(n2)
d) O(log n)
What will be the time complexity of given code?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What will be the time complexity of given code?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!