Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 489 Bytes

README.MD

File metadata and controls

17 lines (10 loc) · 489 Bytes

Sorting Algorithms

Bubble and merge sorts are much faster than the native JavaScript sort.

Bubble sort

Bubble sort looks over the elements, swaps anything that is out of order, and repeats until it is finished.

space complexity: O(1)

time complexity: O(n^2)

Merge sort

Merge sort divides an array of N elements into N arrays of 1 element, merges adjacent arrays in sorted order, and repeats until it is finished.

space complexity: O(n)

time complexity: O(n * log(n))