Home / MCQ Bank / Computer
Computer Miscellaneous On Data Structures

What will be the output of the following code? #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[] = {3,5,2,4}; int n = sizeof(arr)/sizeof(arr[0]); convert(arr , n); printArr(arr, n); return 0; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option B • 1 3 0 2

Related Computer Questions

In a regular expression, what does the metacharacter `$` represent when used at the end of a pattern? The other name for Comet is How many characters in ASCII 8-bit code can represent? What is the term for the process of selecting a representative subset of a larger dataset for analysis? What is the problem in the following variable declaration? float 3Bedroom-Hall-Kitchen?;