Some other Sorting algorithms

Radix sort is a non-comparative sorting algorithm that is used to sort the data in lexicographical (dictionary) order.

It uses counting sort as a subroutine, to sort an array of integer digit by digit and array of strings character by character.

Bucket Sort is a sorting algorithm that divides the unsorted array elements into several groups called buckets. Each bucket is then sorted by using any of the suitable sorting algorithms or recursively applying the same bucket algorithm.

Finally, the sorted buckets are combined to form a final sorted array.

Shell sort is mainly a variation of Insertion Sort. In insertion sort, we move elements only one position ahead. When an element has to be moved far ahead, many movements are involved. The idea of ShellSort is to allow the exchange of far items. In Shell sort, we make the array h-sorted for a large value of h. We keep reducing the value of h until it becomes 1. An array is said to be h-sorted if all sublists of every h’th element are sorted.

Timsort is a hybrid sorting algorithm. It is used to give optimal results while dealing with real-world data.

Timsort has been derived from Insertion Sort and Binary Merge Sort. At first, the array is stored into smaller chunks of data known as runs. These runs are sorted using insertion sort and then merged using the merge sort.

Comb Sort is mainly an improvement over Bubble Sort. Bubble sort always compares adjacent values. So all inversions are removed one by one. Comb Sort improves on Bubble Sort by using a gap of the size of more than 1. The gap starts with a large value and shrinks by a factor of 1.3 in every iteration until it reaches the value 1. Thus Comb Sort removes more than one inversion count with one swap and performs better than Bubble Sort.

Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key values are approximately the same.

Cycle sort is an in-place sorting Algorithm, unstable sorting algorithm, and a comparison sort that is theoretically optimal in terms of the total number of writes to the original array. 

Cocktail Sort is a variation of Bubble sort. The Bubble sort algorithm always traverses elements from left and moves the largest element to its correct position in the first iteration and second-largest in the second iteration and so on. Cocktail Sort traverses through a given array in both directions alternatively. Cocktail sort does not go through the unnecessary iteration making it efficient for large arrays.

Cocktail sorts break down barriers that limit bubble sorts from being efficient enough on large arrays by not allowing them to go through unnecessary iterations on one specific region (or cluster) before moving onto another section of an array.

Strand sort is a recursive sorting algorithm that sorts items of a list into increasing order. It has O(n²) worst time complexity which occurs when the input list is reverse sorted. It has a best case time complexity of O(n) which occurs when the input is a list that is already sorted.

Bitonic Sort is a classic parallel algorithm for sorting.

  • The number of comparisons done by Bitonic sort is more than popular sorting algorithms like Merge Sort [ does O(log N) comparisons], but Bitonic sort is better for parallel implementation because we always compare elements in a predefined sequence and the sequence of comparison doesn’t depend on data. Therefore it is suitable for implementation in hardware and parallel processor array.
  • Bitonic Sort must be done if the number of elements to sort is 2^n. The procedure of bitonic sequence fails if the number of elements is not in the aforementioned quantity precisely.

11. Stooge Sort 

Stooge Sort is a recursive sorting algorithm. It is not much efficient but an interesting sorting algorithm. It generally divides the array into two overlapping parts (2/3 each). After that it performs sorting in first 2/3 part and then it performs sorting in last 2/3 part. And then, sorting is done on first 2/3 part to ensure that the array is sorted.

The key idea is that sorting the overlapping part twice exchanges the elements between the other two sections accordingly.

12. Tag Sort

This is not a new sorting algorithm, but an idea when we need to avoid swapping of large objects or need to access elements of a large array in both original and sorted orders.
A common sorting task is to sort elements of an array using a sorting algorithm like Quick Sort, Bubble Sort.. etc, but there may be times when we need to keep the actual array intact and use a “tagged” array to store the correct positioning of the array when it is sorted. When we want to access elements in a sorted way, we can use this “tagged” array.

Tree sort is a sorting algorithm that is based on Binary Search Tree data structure. It first creates a binary search tree from the elements of the input list or array and then performs an in-order traversal on the created binary search tree to get the elements in sorted order. 

Cartesian Sort is an Adaptive Sorting as it sorts the data faster if data is partially sorted. In fact, there are very few sorting algorithms that make use of this fact. For example consider the array {5, 10, 40, 30, 28}. The input data is partially sorted too as only one swap between “40” and “28” results in a completely sorted order. 

This is basically a variation of bubble-sort. This algorithm is divided into two phases- Odd and Even Phase. The algorithm runs until the array elements are sorted and in each iteration two phases occurs- Odd and Even Phases.
In the odd phase, we perform a bubble sort on odd indexed elements and in the even phase, we perform a bubble sort on even indexed elements.

Merge sort involves recursively splitting the array into 2 parts, sorting, and finally merging them. A variant of merge sort is called 3-way merge sort where instead of splitting the array into 2 parts we split it into 3 parts. Merge sort recursively breaks down the arrays to subarrays of size half. Similarly, the 3-way Merge sort breaks down the arrays to subarrays of size one-third. 

Gnome Sort also called Stupid sort is based on the concept of a Garden Gnome sorting his flower pots. A garden gnome sorts the flower pots by the following method-  

  • He looks at the flower pot next to him and the previous one; if they are in the right order he steps one pot forward, otherwise, he swaps them and steps one pot backward.
  • If there is no previous pot (he is at the starting of the pot line), he steps forwards; if there is no pot next to him (he is at the end of the pot line), he is done.

Cocktail Sort is a variation of Bubble sort. The Bubble sort algorithm always traverses elements from the left and moves the largest element to its correct position in the first iteration and the second-largest in the second iteration and so on. Cocktail Sort traverses through a given array in both directions alternatively. Cocktail sort does not go through the unnecessary iteration making it efficient for large arrays.

Cocktail sorts break down barriers that limit bubble sorts from being efficient enough on large arrays by not allowing them to go through unnecessary iterations on one specific region (or cluster) before moving onto another section of an array.

Introduction to Sorting Techniques – Data Structure and Algorithm Tutorials

Sorting refers to rearrangement of a given array or list of elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of elements in the respective data structure.

When we have a large amount of data, it can be difficult to deal with it, especially when it is arranged randomly. When this happens, sorting that data becomes crucial. It is necessary to sort data in order to make searching easier.

Similar Reads

Types of Sorting Techniques

There are various sorting algorithms are used in data structures. The following two types of sorting algorithms can be broadly classified:...

Why Sorting Algorithms are Important

The sorting algorithm is important in Computer Science because it reduces the complexity of a problem. There is a wide range of applications for these algorithms, including searching algorithms, database algorithms, divide and conquer methods, and data structure algorithms....

Some of the most common sorting algorithms are:

Below are some of the most common sorting algorithms:...

1. Selection sort

Selection sort is another sorting technique in which we find the minimum element in every iteration and place it in the array beginning from the first index. Thus, a selection sort also gets divided into a sorted and unsorted subarray....

2. Bubble sort

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. This algorithm is not suitable for large data sets as its average and worst-case time complexity is quite high....

3. Insertion Sort

Insertion sort is a simple sorting algorithm that works similarly to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in the sorted part....

4. Merge Sort

The Merge Sort algorithm is a sorting algorithm that is based on the Divide and Conquers paradigm. In this algorithm, the array is initially divided into two equal halves and then they are combined in a sorted manner....

5. Quick sort

Quicksort is a sorting algorithm based on the divide and conquer approach where an array is divided into subarrays by selecting a pivot element (element selected from the array)....

6. Heap sort

Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements....

7. Counting sort

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values (kind of hashing). Then do some arithmetic to calculate the position of each object in the output sequence....

Some other Sorting algorithms:

1. Radix sort...

Comparison of Complexity Analysis Between Sorting Algorithms:

NameBest Case  Average Case  Worst Case MemoryStable   Method UsedQuick Sort[Tex]n log n[/Tex][Tex]n log n[/Tex][Tex]n^{2}[/Tex][Tex]log n[/Tex]NoPartitioningMerge Sort[Tex]n log n[/Tex][Tex]n log n[/Tex][Tex]n log n[/Tex]nYesMergingHeap Sort[Tex]n log n[/Tex][Tex]n log n[/Tex][Tex]n log n[/Tex]1NoSelectionInsertion Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1YesInsertionTim Sortn[Tex]n log n[/Tex][Tex]n log n[/Tex]nYesInsertion & MergingSelection Sort[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1NoSelectionShell Sort[Tex]n log n[/Tex][Tex]n^{4/3}[/Tex][Tex]n^{3/2}[/Tex]1NoInsertionBubble Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1YesExchangingTree Sort[Tex]n log n[/Tex][Tex]n log n[/Tex][Tex]n log n[/Tex]nYesInsertionCycle Sort[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1NoSelectionStrand Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]nYesSelectionCocktail Shaker Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1YesExchangingComb Sort[Tex]n log n[/Tex][Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1NoExchangingGnome Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1YesExchangingOdd–even Sortn[Tex]n^{2}[/Tex][Tex]n^{2}[/Tex]1YesExchanging...

Contact Us