Q319
What will be the output of the following code? #include using namespace std; void convert(int arr[], int n) int temp[n]; memcpy(temp, arr, n*sizeof(int)); sort(temp, temp + n); unordered_map 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;
A.
0 2 3 4
B.
1 3 0 2
AnswerC.
2 4 1 3
D.
1 2 3 4
Answer: Option B
Solution
Answer: Option B
No explanation is given for this question Let's Discuss on Board