Visual Demonstration of the QuickSort Algorithm
Why Stack Overflow recommends it
Stack Overflow users link it when they want a concrete picture of how QuickSort partitions an array and places pivots, especially when debugging their own implementations.
Recommended by 0 people across 0 different months, 2013 to 2013.
What it is
A short screen-capture animation that shows the QuickSort algorithm running step by step, with a link to a blog post that explains the visualization. It is posted by the channel vladb01 and contains no spoken lecture.
What people said
Cites Andrew Martin · 2013-02 · Stack Overflow · on “Quicksort Algorithm not assigning pivot correctly”
I watched this fantastic visualization of a quick sort algorithm: [this video] I felt I really understood the principles behind quick sort and, with the help of some guides online, set about creating my own quick sort. This is what I came up with: public void quickSort(int[] a, int left, int right) { int index = partition(a, left, right); if (left < index - 1) quickSort(a, left, index); if (index < right) quickSort(a, index + 1, right); } private int partition (int[] a, int left, int right) { int i = left - 1; int j = right + 1; int pivot = a[0]; while (i < j) { i++; while (a[i] < pivot) i++; j--; while (a[j] > pivot) j--; if (i < j) swap (a, i, j); } return i; } private void swap (int[] a, int i
Cites Atle S · 2013-03 · Stack Overflow · on “Optimization or wrong implementation of QuickSort”
I think the problem is the youtube description of this problem: [this video] It holds the actual placement of the element and only quicksort on both sides of it, but instead it could be between two elements as long as left only contains smaller or same, and right contains smaller or same. And it's no need to do the last cleanup when you know that part holds?
Cites sircodesalot · 2013-09 · Stack Overflow · on “Algorithm:Sort using Median and Just 1 comparison in $ O(n \log n) $”
Quicksort (presented in reverse order) works like this. Suppose you have an array: [1, 4, 5, 2, 3] Quicksort in the abstract basically works by sliding towards the middle of the array from both the left and the right side. As we slide inwards, we want to swap items such that big things get moved to the right, and small things get moved to the left. Eventually we should have an array where all the small stuff is on the left, and all the big stuff is on the right. The upshot of this process also guarantees that one element will be placed in the correct location (because everything to the left of it will be smaller, and everything to the right will be bigger, so it must be in the right position