Learn
Quicksort: Python
Quicksort Review

Congratulations on implementing the quicksort algorithm in Python. To review:

  1. We established a base case where the algorithm will complete when the start and end pointers indicate a list with one or zero elements
  2. 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
  3. We then iterate through that list and track all the “lesser than” elements by swapping them with the iteration index and incrementing a lesser_than_pointer.
  4. Once we’ve iterated through the list, we swap the pivot element with the element located at lesser_than_pointer.
  5. With the list partitioned into two sub-lists, we repeat the process on both halves until base cases are met.

Instructions

1.

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!

Folder Icon

Sign up to start coding

Already have an account?