|
| 1 | +Quicksort |
| 2 | + |
| 3 | +A quicksort is a quicker method of sorting, and there are four different ways of implementing it. The example given uses a pivot point. |
| 4 | + |
| 5 | +A pivot point is created in the middle of an array, and all larger items go after the pivot point, and smaller items are placed in front |
| 6 | +of the pivot point. |
| 7 | + |
| 8 | +The pivot point is then moved to the middle of either the smaller or larger items, and the sort is run again on that half. |
| 9 | + |
| 10 | +This continues over and over again until everything is in the proper place. |
| 11 | + |
| 12 | +Usage |
| 13 | +from allalgorithms.sorting import quicksort |
| 14 | + |
| 15 | +arr = [77, 2, 10, -2, 1, 7] |
| 16 | + |
| 17 | +print(quicksort(arr)) |
| 18 | +# -> [-2, 1, 2, 7, 10, 77] |
| 19 | + |
| 20 | +API |
| 21 | + |
| 22 | +quicksort(array) |
| 23 | +Returns a sorted array |
| 24 | + |
| 25 | +Params: |
| 26 | +array: Unsorted Array |