//bubble sort // Big O notation: O(n²) //takes in array and array length for i = 0 to array_length for j = to array_length - i - 1 if array[j] > array[j+1] swap array[j] with array[j+1]
//quick sort // Big O notation: O(n log(n)) //takes in array and start index and end index if start < end result = partition(array, start, end) recursively call self (array, start, result - 1) recursively call self (array, result + 1,end) //partition //takes in array, low and high //sets pivot to last element and moves it to correct //position then move all elements less to pivot to //its left and greater to its right pivot = array[high] index = low - 1 for j = 0, j less or equal to high - 1 if array[j] < pivot index++ swap array[i] with array[j] swap array[index + 1] with array[high] return index + 1
//Merge Sort // Big O notation: O(n log(n)) //takes in array, start and end if start < end mid = (start + end)//2 recursively call self (array, start, mid) recursively call self (array, mid + 1,end) merge(array, start, mid, end) //merge //takes in array, start, mid and end index = 0 left = start right = mid + 1 tempArray = [] while left <= mid && right <= end if array[left] &t= array[right] tempArray[index] = array[left] left++ else tempArray[index] = array[right] right++ index++ if left > mid for i = right, less or equal to end tempArray[index++] = array[i] else for i = left, less or equal to mid tempArray[index++] = array[i] for k = 0 to array_length array[start++] = tempArray[k] return array
//Selection sort // Big O notation: O(n²) //takes in array for i = 0 to array length small = array[i] pos = 0 for j = i + 1 to array length if array[j] < small small = array[j] pos = j swap array[pos] with array[i]