What Is The Time Complexity Of The Following Codep Pre Langc #418
What is the time complexity of the following code?</p> <pre><code class="language-c"> #include <bits/stdc++.h> using namespace std; void convert(int arr[], int n) { int temp[n]; memcpy(temp, arr, n*sizeof(int)); sort(temp, temp + n); unordered_map<int, int> map; int sort_index = 0; for (int i = 0; i < n; i++) map[temp[i]] = sort_index++; for (int i = 0; i < n; i++) arr[i] = map[arr[i]]; } void printArr(int arr[], int n) { for (int i=0; i<n; i++) cout << arr[i] << " "; } int main() { int arr[] = {10, 20, 15, 12, 11, 50}; int n = sizeof(arr)/sizeof(arr[0]); convert(arr , n); printArr(arr, n); return 0; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Miscellaneous - Co-ordinate Compression - Quiz No.1.
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes