Inversion count of an array

Given an array, find the number of inversions of it. If (i < j) and (A[i] > A[j]) then the pair (i, j) is called an inversion of an array A. We need to count all such pairs in the array.

Custom Sort | Sort array based on another array

Given two arrays, reorder elements of first array by order of elements defined by the second array.   Elements which are not present in the second array but present in first array should be appended in the end sorted. Second array can contain some extra elements which are not part of first array.

Custom Sort | Sort elements by their frequency and Index

Given an array, sort its element by their frequency and index. i.e. – If two elements have the different frequencies, then the one which has more frequency should come first. – If two elements have the same frequencies, then the one which has less index should come first.

External Merge Sort Algorithm

We can efficiently sort massive amounts of data using External Merge Sort Algorithm, when the data being sorted don’t fit into the main memory (which is usually RAM) and resides in the slower external memory (which is usually a hard disk).

Hybrid QuickSort Algorithm

In this article, hybrid of Quick Sort algorithm with Insertion Sort is discussed to achieve better performance.

Quicksort Algorithm

Given an array of integers, sort it using quicksort algorithm.   Quicksort is an efficient in-place¬†sorting algorithm, which usually performs about two to three times faster than merge sort and heapsort when implemented well.¬†

Merge Sort Algorithm

Given an array of integers, sort it using merge sort algorithm.     Merge sort is an efficient in-place sorting algorithm which produces a stable sort, which means that if two elements have the same value, they holds same relative position in the output as they did in the input.

Bubble Sort Algorithm | Iterative & Recursive

Given an array of integers, sort it using bubble sort algorithm.     Bubble sort is a stable, in-place sorting algorithm that is named for the way smaller or larger elements “bubble” to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared …