Sorting Algorithm | Quick Sort - step by step guide
Why Stack Overflow recommends it
Stack Overflow users cite it as the quicksort reference they followed when implementing or debugging their own C, C++ and JavaScript versions.
Recommended by 1 people across 1 different months, 2015 to 2017.
What it is
A 10-minute walkthrough of the quicksort algorithm by Yusuf Shakeel, shown as a step-by-step animation of an array being partitioned rather than as code. It covers the recursive steps, the left/right/pivot rule, each pivot pass on a small example, and a short note on the algorithm and its order of complexity.
What people said
Recommends Henrik Ståhlberg · 2015-05 · Stack Overflow · on “C++ quicksort implementation crashes; also style advices”
I reworked your sorting code some to make it more efficient //END THE RECURSION if ((end - start) <= 0) { return; } //SORTING PART else { int pivot = (start + end) / 2; int left = start; // Set left to first element int right = end; // Set right to last element while (left < right) { if (numbers[left] > numbers[pivot]) // If left is greater then pivot swap them { double temp = numbers[left]; numbers[left] = numbers[pivot]; numbers[pivot] = temp; pivot = left; // Pivot is now left } if (numbers[right] < numbers[pivot]) // If right is smaller then pivot { double temp = numbers[right]; numbers[right] = numbers[pivot]; numbers[pivot] = temp; pivot = right; // Pivot is now right } left++; right--
Cites user5910213 · 2016-03 · Stack Overflow · on “Why is this quicksort code in C not sorting?”
[this video] I saw this video and implemented as it is . Now tell me where am i wrong. Once again i would say there is no compilation error
Cites Relu Mesaros · 2016-08 · Stack Overflow · on “Native JavaScript sort performing slower than implemented mergesort and quicksort”
I've implemented a mergesort and a quicksort to compare them with the native JavaScript sort. For the quicksort I've tried to use this algorithm: view algorithm on youtube [this video] . Both algorithms use as less memory as possible, for the merge sort an auxiliary array is passed for each recursive call (to avoid overheads) , and for the quicksort, positions of the starting and ending positions. I'm using sorts to manage large amounts of data in a NodeJs app. Below you have the mergesort, quicksort and native JavaScript sort and you can test the performance The question is: Why is the native JavaScript performing slower ? In my case: Chrome - merge sort: measure: 1997.920ms; quicksort: measure:
Cites Jordan · 2017-06 · Stack Overflow · on “Quick sorting in C. How to conquer the divides?”
So I am trying to teach myself how to implement a quick sort using C. I watched this video to learn the concept: [this video] I think have mastered the concept of sorting to produce two separate sub-arrays, however I am confused about what would be the most efficient way to handle the many following sub-arrays. It seems you would need to keep track of the position of the sorted numbers within the array, and then process where those sorted numbers are in order to figure out where to begin sorting the next sub-array. This doesn't seem very efficient to me. The way I am planning on handling this is to store the sorted numbers' position in a separate array, and do a scan of this array between ever it