Count number of pair of elements whose difference is smaller than average difference

Given an array of positive integers we have to find number of pair of elements whose difference is smaller than average difference. Average difference is defined as (max(A)-min(A))/(n-1), where A is the array and max(A),min(A) is the maximum and minimum element of the array. Examples: Input : {9,3,10,2,3} Output : 2 Input : {7,9,5,3,1} Output : 0 RECOMMENDED: Characteristics or… Read More »

Introduction of Radix Sort

Radix Sort is the answer when elements are in the range from 1 to n^2. The idea of Radix Sort is to do digit by digit sort starting from least significant digit to most significant digit. Radix sort uses counting sort as a subroutine to sort. Radix Sort: Radix Sort basically consists of the following steps: Take the… Read More »