
Input: 'N' = 4, 'ARR' = [0.79, 0.66, 0.65, 0.12]
Output: [0.12, 0.65, 0.66, 0.79]
The given array, after sorting in a non-decreasing manner looks like the output given.
The first line will contain the integer 'T', denoting the number of test cases.
The first line for each test case contains a single integer 'N', the size of the array ‘ARR’.
The second line will contain ‘N’ integers representing the array elements.
For each test case, print the minimum sum of elements.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' <= 10^5
0 <= ‘ARR[i]’ <= 1, ARR[i] is of exactly 2 decimal places.
Time Limit: 1 sec
In most languages, we have an inbuilt sort function that we can use to sort our array ‘ARR’.
We know that counting sort takes O( N ) time to sort an array whose elements are less than <10^6 if we talk about c++, We can not make an array greater than that, also we use array elements as indices there, but here numbers are floating-point so we can not use an array here now what if we take the map for storing the number than we know a general map uses a hash table( not talking about map in c++ STL ) and if two keys have the same hash function we can do a linear search from there to an empty space in the hash table and in the worst case this searching can take O(N) time and total time complexity can go up to O(N^2) in the worst case just for storing so we can not use the map as well. We are trying to solve it in linear time for that we can use bucket sort where we make a few buckets and insert the numbers in those buckets and then we sort those buckets using insertion sort.
InsertionSort( ARR)
sortArray( ARR )