Quicksort

The last sorting algorithm described in this book is named quicksort. It is one of the popular divide and conquer algorithms, which divide a problem into a set of smaller ones. Moreover, such an algorithm provides developers with an efficient way of sorting. Does this mean that its idea and implementation are very complicated? Fortunately, no! You will learn how the algorithm works, as well as what its implementation code can look like in this section. Let's start!

How does the algorithm work? At the beginning, it picks some value (such as from the first or the middle element of the array) as a pivot. Then, it reorders the array in such a way that values lower than or equal to the pivot are placed before it (forming the lower subarray), ...

Get C# Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.