TC : O(n^2) SC : O(1)
(arr: list)
| 63 | |
| 64 | |
| 65 | def insertion_sort(arr: list) -> list: |
| 66 | """TC : O(n^2) |
| 67 | SC : O(1)""" |
| 68 | n = len(arr) |
| 69 | for i in range(1, n): |
| 70 | for j in range(i, 0, -1): |
| 71 | if arr[j - 1] > arr[j]: |
| 72 | arr[j - 1], arr[j] = arr[j], arr[j - 1] |
| 73 | else: |
| 74 | break |
| 75 | return arr |
| 76 | |
| 77 | |
| 78 | def merge_sort(arr: list) -> list: |
nothing calls this directly
no outgoing calls
no test coverage detected