Sequential Search
O(n)
works on sorted and unsorted data sets
finds the first occurrence from the starting point
Binary Search
O(log(n))
works only on sorted data sets (sorting direction is indifferent)
divides the data in binary tree fashion
finds the 1st occurrence which is on a higher level of the binary tree
uses shortcuts for the 1st and the last elements
EXAMPLE FOR SEQUENTIAL SEARCH:
EXAMPLE FOR BINARY SEARCH:
EXAMPLE FOR SEQUENTIAL SEARCH:
EXAMPLE FOR BINARY SEARCH:
Selection Sort:
O(n²)
not suitable for large lists due to its inefficiency
useful in scenarios where memory writes are a costly operation (makes maximum n - 1 swaps)
Bubble Sort
O(n²)
not suitable for large data sets due to its inefficiency
Insertion Sort
O(n²)
efficient for small data sets or for lists that are already mostly sorted
useful in real-time applications where data arrives continuously
Minimum Search Sort
O(n²)
efficient when number of data swaps must be kept at minimum
Merge Sort
O(n * log(n))
employs a divide-and-conquer strategy
efficient and stable, with a predictable time complexity
performs well on large data sets
performs not as well on small data sets
particularly useful for linked lists and external sorting (e.g., sorting large files on disk)
EXAMPLE FOR SELECTION SORT:
EXAMPLE FOR BUBBLE SORT:
EXAMPLE FOR INSERTION SORT:
EXAMPLE FOR MINIMUM SEARCH SORT:
EXAMPLE FOR SELECTION SORT:
EXAMPLE FOR BUBBLE SORT:
EXAMPLE FOR INSERTION SORT:
EXAMPLE FOR MINIMUM SEARCH SORT: