Congratulations on implementing the quicksort algorithm in Python. To review:
- We established a base case where the algorithm will complete when the
endpointers indicate a list with one or zero elements
- If we haven’t hit the base case, we randomly selected an element as the pivot and swapped it to the end of the list
- We then iterate through that list and track all the “lesser than” elements by swapping them with the iteration index and incrementing a
- Once we’ve iterated through the list, we swap the pivot element with the element located at
- With the list partitioned into two sub-lists, we repeat the process on both halves until base cases are met.
We’ve included the complete quicksort algorithm with some extra comments and print statements. Run the code to see a more detailed breakdown of each step!