Home / MCQ Bank / Computer
Computer Miscellaneous On Data Structures Difficulty: Medium

What will be the time complexity of given code? #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], i)); sort(vec.begin(), vec.end()); for (int i=0; i<n; i++) a[vec[i].second] = i; } void printArr(int a[], int n) { for (int i=0; i<n; i++) cout << a[i] << " "; } int main() { int arr[] = {10,8,2,5,7}; int n = sizeof(arr)/sizeof(arr[0]); convert(arr , n); printArr(arr, n); return 0; }

Select the correct option to test your answer:

More Computer Questions

What is the output of the following code: my_list = [1, 2, 3] del my_list[1] print(my_list) What is the output of the following code: my_string = "Hello, World!" print(my_string.upper()) Which of the following is not a type of Constructor? Consider the following code snippet : var c = counter () , d = counter () ; function constfuncs () { var funcs = [] ; for(var i = 0 ; i < 10 ; i ++ ) funcs [ i ] = function () { return i; } ; return funcs; } var funcs = constfuncs () ; funcs [ 5 ]() What does the last statement return ? What is the correct way to declare a method named PrintMessage that prints a message to the console without taking any parameters or returning any value in C#?