We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 9
Sorting
AlgorithmsBubble 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 complexities
is quite high.
Bubble SortHeap 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 remaining
elements.Insertion Sort
Insertion sort is a simple sorting algorithm that
works similar to the way you sort playing cards
in your hands The array is virtualy 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.
Assume 54 is a sorted
list of 1 item
inserted 26
inserted 93
inserted 17
inserted 77
inserted 44
"PEPE EEEE) ~~Merge Sort
Merge Sort is a algorithm that is considered
an example of the divide and conquer strategy.
So, in this algorithm the array is initially divided
into two equal halves and then they are combine
in a sorted manner.Quick Sort
Quick sort is also an divide and conquer algorithm.
It picks an element as a pivot and partitions
the given array around the picked pivot. This
algorithm is used to quickly sort items within an
array no matter how big the array is.Selection Sort
The Selection sort algorithm sorts an array by
repeatedly finding the minimum element
(considering ascending order) from unsorted
part and putting it at the beginning.Shell Sort
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.
1 shift for 20
2 shifts for 31
1 shift for 54
sortedTime Complexities
Sorting Best Average Worst
Algorithm Case Case Case
Bubble Om) Om’) Om’)
Sort
Heap Sort | O(nlog | O(nlogn) | O(nlogn)
n
Insertion O(n) O(n’) Om’)
Sort
Merge Sort | O(nlog | O(mlogn) | O(mlogn)
n)
Quick Sort | O(nlog | O(nlogn) | O(n)
n)
Selection O~n) On) O(n’)
Sort
Shell Sort | O(ni Om 7) O(n)
(log
ny’)