Merge Sort

Time Complexity

Average - θ(n log(n))

Worst - O(n log(n))

Explanation

Recursively divides an array into smaller subarrays, sorting each subarray, then merging the sorted subarrays together.

Here is an in-depthexplanation

  • Comparing & Swapping

Quick Sort

Time Complexity

Average - θ(n log(n))

Worst - O(n^2)

Explanation

Recursively partitions the array, moving elements smaller than the pivot, to the left of the pivot and elements larger to the right.

Here is an in-depthexplanation

  • Comparing
  • Swapping
  • Pivot

Bubble Sort

Time Complexity

Average - θ(n^2)

Worst - O(n^2)

Explanation

Loops through array for each element, comparing adjacent elements, moving the larger element to the right.

Here is an in-depthexplanation

  • Comparing
  • Swapping

Selection Sort

Time Complexity

Average - θ(n^2)

Worst - O(n^2)

Explanation

Loops through array for each element, keeping track of the last minimum value seen, and moving it to the start of the loop.

Here is an in-depthexplanation

  • Comparing
  • Swapping
  • Last Minimum Value