From the course: Python: Recursion

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Introduction to quicksort

Introduction to quicksort - Python Tutorial

From the course: Python: Recursion

Introduction to quicksort

- [Instructor] We are now going to look at an important recursive algorithm for sorting data, the Quicksort Algorithm. Quicksort is an efficient and powerful algorithm for sorting data. Some variant of it is used in libraries for several common programming languages. It's based on a technique called divide and conquer which means taking a problem and breaking it down into smaller sub-problems which are similar but easier to solve than the original problem. Here's the algorithm in pseudo code. So given an array of n elements, for example integers, if an array contains a zero or one elements, then you return. But this would be the base case. Otherwise you pick one element to use as a pivot. You partition elements into three sub-arrays. So you have elements which are less than the pivot. Elements which have the same value as the pivot and elements which are greater than the pivot. And then you recursively call Quicksort on…

Contents