From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Check your understanding of quicksort

Solution: Check your understanding of quicksort - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

Solution: Check your understanding of quicksort

(upbeat music) - [Instructor] And here's a solution for chapter five challenge. Taking the list five, four, three, two, one. You can see how it gets broken down around the pivot three in the middle, and then each of those sub arrays of length two gets broken down into further sub arrays and you can see the result there. I just want to clarify what's happening in the partitioning stage of this algorithm. So, as we split our initial list, we don't split it in terms of the physical location, if you like, of the elements, but in terms of their value. So, for example, going from the initial list on the slide to the next laid down, we don't have five, four in the left hand list, and then two, one in the right hand list, because that's not how the algorithm works. Remember, we're partitioning based on the value compared to the pivot. So, if the pivot is three, then the items on the left hand side of that will be two and…

Contents