diff --git a/src/blog/array-sort.md b/src/blog/array-sort.md index 55a2ced0e..63f8e92b5 100644 --- a/src/blog/array-sort.md +++ b/src/blog/array-sort.md @@ -175,7 +175,7 @@ The second pre-processing step is the removal of holes. All elements in the sort Choosing a suitable pivot element has a big impact when it comes to Quicksort. V8 employed two strategies: -- The pivot was chosen as the median of the first, last and a third element of the sub-array that gets sorted. For smaller arrays that third element is simply the middle element. +- The pivot was chosen as the median of the first, last, and a third element of the sub-array that gets sorted. For smaller arrays that third element is simply the middle element. - For larger arrays a sample was taken, then sorted and the median of the sorted sample served as the third element in the above calculation. One of the advantages of Quicksort is that it sorts in-place. The memory overhead comes from allocating a small array for the sample when sorting large arrays, and log(n) stack space. The downside is that it’s not a stable algorithm and there’s a chance the algorithm hits the worst-case scenario where QuickSort degrades to O(n^2).