The following editor will bring you a Java quick sorting QuickSort (example). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look
Quick sort
---------------- -------------------------------------------------- ----
Thoughts
As shown above: At the beginning of each quick sort, set a key, key=array[ low], then go from high to the left, find the value that is less than the key, copy it to the low position, then go from low to the right to find the value that is greater than the key, copy it to the high position, until the end of low=high,
will The key is copied to the low position.
In the above figure, after the first round of division, the position of 32 is found, and then the left and right sides of 32 are sorted recursively.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
The above is the detailed content of Java implementation of quick sorting QuickSort example. For more information, please follow other related articles on the PHP Chinese website!