---
# System prepended metadata

title: ALGORITHMS

---

# ALGORITHMS

## SELECTION SORT
### When to use:
Selection sort can be good at checking if everything is already sorted. It is also good to use when
memory space is limited. This is because unlike other sorting algorithms, selection sort doesn’t
go around swapping things until the very end, resulting in less temporary storage space used.
### Complexity:
B: Ω(n^2)
A: θ(n^2)
W: O(n^2)

## HEAP SORT
### When to use:
Heap Sort is not used much in practice, but can be useful in real time (or time bound where QuickSort
doesn’t fit) embedded systems where less space is available (MergeSort doesn’t fit).
Heapsort shall be used if you don’t have any extra space. 
### Complexity:
B: Ω(n log(n))
A: θ(n log(n))
W: O(n log(n))

## BUBBLE SORT
### When to use:
Bubble sort is easy to implement and it is fast enough when you have small data sets. It can be
good if swap of two adjacent items is chip and swap of arbitrary items is expensive.
### Complexity:
B: Ω(n)
A: θ(n^2)
W: O(n^2)

## MERGE SORT
### When to use:
Merge sort is more efficient and works faster than quick sort in case of larger array size or
datasets.
### Complexity:
B: Ω(n log(n))
A: θ(n log(n))
W: O(n log(n))

## QUICK SORT
### When to use:
Quick sort is more efficient and works faster than merge sort in case of smaller array size or
datasets. Sorting method : The quick sort is internal sorting method where the data is sorted in
main memory.
### Complexity:
B: Ω(n log(n))
A: θ(n log(n))
W:O(n^2)

## BINARY SEARCH ALGORITHM
### When to use:
Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by
repeatedly dividing in half the portion of the list that could contain the item, until you&#39;ve
narrowed down the possible locations to just one.
### Complexity:
The time Complexity of the binary search algorithm is O(log n). The best-case time Complexity would be
O(1) when the central index would directly match the desired value. The worst-case scenario could be
the values at either extremity of the list or values not in the list.

## INSERTION SORT
### When to use:
insertion sort only scans as many elements as necessary. That means that when the array is
already sorted or almost sorted, insertion sort performs in O(n) time.
### Complexity:
B: Ω(n)
A: θ(n^2)
W: O(n^2)