# Tag Archives: python sorting-exercises

Prerequisite : HeapSort  Heap sort is a comparison based sorting technique based on Binary Heap data structure. It is similar to selection sort where we… Read More
The Stooge sort is a recursive sorting algorithm. It is defined as below (for ascending order sorting). Step 1 : If value at index 0… Read More
Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. Below is an iterative algorithm for insertion sortAlgorithm… Read More
Cycle sort is an in-place sorting Algorithm, unstable sorting algorithm, a comparison sort that is theoretically optimal in terms of the total number of writes… Read More
The purpose of Bisect algorithm is to find a position in list where an element needs to be inserted to keep the list sorted. Python… Read More
BogoSort also known as permutation sort, stupid sort, slow sort, shotgun sort or monkey sort is a particularly ineffective algorithm based on generate and test… Read More
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… Read More
Algorithm Steps: If you are at the start of the array then go to the right element (from arr to arr). If the current array… Read More
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… Read More
Bitonic Sequence: A sequence is called Bitonic if it is first increasing, then decreasing. In other words, an array arr[0..n-i] is Bitonic if there exists… Read More
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… Read More
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… Read More
Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Python   Python # Recursive Python Program for merge sort… Read More
We can use binary search to reduce the number of comparisons in normal insertion sort. Binary Insertion Sort find use binary search to find the… Read More
In shellSort, we make the array h-sorted for a large value of h. We keep reducing the value of h until it becomes 1. An… Read More