In this chapter, you’ll learn how to implement algorithms such as quicksort, mergesort, and bubble sort.
Quicksort
Quicksort is a divide-and-conquer algorithm. Quicksort divides a large array into two smaller subarrays, known as the low elements and high elements. The time complexity in the best case is O(n log n) and in the worst case is O(n2).
- 1.
Choose an element from the array. The element will be called the pivot .
- 2.
Reorder the array in such a way that all the elements ...