
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains an integer N, the size of the array.
The second line of each test case contains N space-separated integers, the elements present in the array.
For every test case, the only line of output should contain N space-separated integers in sorted order.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5
10^-9<= arr[i] <= 10^9
Time limit: 1 sec
In the QuickSort Algorithm, we do the partitioning of the array into smaller arrays. We partition our array into two smaller arrays such that elements of one sub-array are smaller than the pivot element and the elements of the other sub-array are greater than the pivot element.
Algorithm:
The idea is to apply the divide and conquer approach to sort the array. As the name says this algorithm is inspired by the Dutch Flag which is made up of three colors: Red, White, and Blue. With respect to a particular element(‘pivot’), we can put the array elements groups into different groups. The red group will contain all the elements which are lesser than the pivot, the blue group will have elements that are greater than the pivot and finally, and the white group will have elements that are equal to the pivot element.
The algorithm is as follows:
Similar to the QuickSort algorithm start by making a pivot element. Let’s call the elements that are not visited the ‘notVisited’ elements and as soon as we’re done traversing the array we can visualize our array as a composition of 5 regions.
Algorithm: