


You are given arr = {1, 3, 8, 6, 7}, then our answer will be 3.
Sorted form of arr = {1, 3, 6, 7, 8}. The maximum absolute difference between two consecutive elements is 6 - 3 = 3, which is the correct answer.
The first line contains an integer 'T' which denotes the number of test cases.
The first line of each test case contains an integer denoting the size of the ‘arr’.
The second contains ‘N’ space-separated integers representing the elements of the array ‘arr’.
For each test case, print a single integer, denoting the maximum difference between two consecutive elements in the sorted form of ‘arr’.
The output of each test case will be printed in a separate line.
1 <= T <= 10
1 <= N <= 10 ^ 6
0 <= arr[i] <= 10 ^ 9
Time limit: 1 sec
You do not need to input or print anything, as it has already been taken care of. Just implement the given function.
In this approach, we will first sort the given array, find every consecutive pair of elements, and return the maximum difference. We will maintain a variable maxDiff to store the maximum difference.
Algorithm:
This approach is similar the approach 1. The difference is that in this approach, we will use radix sort instead of comparison sort to sort the input array. Radix sort sorts the array by performing counting sort on individual digits starting from least significant digit to most significant digit.
Algorithm:
In this approach, we will divide elements into buckets. We will store minimum and maximum values for each bucket and compare them to find the final answer. Bucket Sort stores elements into buckets of some fixed size and then sorts each bucket, which takes less processing time as compared to comparison sorts.
Algorithm: