Sorting Algorithm: 1. Heapsorting Heap Sort Is A Comparison Based Sorting Technique Based On Binary Heap Data
Sorting Algorithm: 1. Heapsorting Heap Sort Is A Comparison Based Sorting Technique Based On Binary Heap Data
Sorting Algorithm
1. HeapSorting
Heap Sort is a comparison based sorting technique based on Binary Heap data
structure. It is similar to selection sort where we first find the maximum element
and place the maximum element at the end. We repeat the same process for the
remaining elements. A Binary Heap is a Complete Binary Tree where items are
stored in a special order such that value in a parent node is greater(or smaller) than
the values in its two children nodes. The former is called as max heap and the latter
is called min-heap. The heap can be represented by a binary tree or array.
2. Insertion Sorting
Insertion Sort is a sorting algorithm in which the elements are transferred one at a
time to the right position. In other words, an insertion sort helps in building the
final sorted list, one item at a time, with the movement of higher-ranked elements.
An insertion sort has the benefits of simplicity and low overhead. In an insertion
sort, the first element in the array is considered as sorted, even if it is an unsorted
array. In an insertion sort, each element in the array is checked with the previous
elements, resulting in a growing sorted output list. With each iteration, the sorting
algorithm removes one element at a time and finds the appropriate location within
the sorted array and inserts it there. The iteration continues until the whole list is
sorted.
3. Merge Sorting
Merge Sort is a function repeatedly divides the array into two halves until we
reach a stage where we try to perform MergeSort on a subarray . First ,divides the
array into equal halves and then combines them in a sorted manner then merge the
smaller lists into new list in sorted order.
4. Quick Sorting
5. Selection Sorting
Selection Sort is a simple sorting algorithm. This sorting algorithm is an in-place
comparison-based algorithm in which the list is divided into two parts, the sorted
part at the left end and the unsorted part at the right end. Initially, the sorted part is
empty and the unsorted part is the entire list.The smallest element is selected from
the unsorted array and swapped with the leftmost element, and that element
becomes a part of the sorted array. This process continues moving unsorted array
boundary by one element to the right.
6. Shell Sorting
Shell Sort is a highly efficient sorting algorithm and is based on insertion sort
algorithm. This algorithm avoids large shifts as in case of insertion sort, if the
smaller value is to the far right and has to be moved to the far left.This algorithm
uses insertion sort on a widely spread elements, first to sort them and then sorts the
less widely spaced elements. This spacing is termed as interval.