Example: >>> lomuto_partition([1,5,7,6], 0, 3) 2
(sorting: list, left: int, right: int)
| 73 | |
| 74 | |
| 75 | def lomuto_partition(sorting: list, left: int, right: int) -> int: |
| 76 | """ |
| 77 | Example: |
| 78 | >>> lomuto_partition([1,5,7,6], 0, 3) |
| 79 | 2 |
| 80 | """ |
| 81 | pivot = sorting[right] |
| 82 | store_index = left |
| 83 | for i in range(left, right): |
| 84 | if sorting[i] < pivot: |
| 85 | sorting[store_index], sorting[i] = sorting[i], sorting[store_index] |
| 86 | store_index += 1 |
| 87 | sorting[right], sorting[store_index] = sorting[store_index], sorting[right] |
| 88 | return store_index |
| 89 | |
| 90 | |
| 91 | def three_way_radix_quicksort(sorting: list) -> list: |
no outgoing calls
no test coverage detected