Quick sort: is an improvement to the bubbling sort.
What is bubble sort: The simple thing is to take bubbles. The extremum data will reach the top of the data.
Implementation steps: Set up a data alignment standard, from big to small to large.
"From large to small arrangement": from the first data to traverse, compare the size of the adjacent two data, large put front, small put back . The smallest one after a walk is the last.
Then go on, traverse the second pass, and the second small one is to the bottom 2nd.
etc...
"From small to large": starting from the first data, compare the size of the adjacent two data, small put front, big put back . According to this.
n elements are arranged and need to traverse N-1 times. That is, the largest subscript of the array. Each comparison is decremented in turn. For N-1 to 0. It is not difficult to figure out the number of bubble sort operations for n elements.
The principle of fast sorting: to subdivide data infinitely by the overall size.
In the case of n elements.
For example: 100 people randomly play on the playground, the teacher said: Let's line up, from short to high, listen to my command. You first in a row, no matter how tall.
OK, it's in a row. The teacher said: All the taller than the first one occupies the left column. It's all lined up then.
Then the teacher said: "Now everyone has seen it." You are two columns now. Now, I'm going to say a standard, you follow the standard.
That is: shorter than the first person in the column to open a column on the left, others do not move. The same height, go to the new column (or do not move), until everyone in the end in a row.
from a column into a row , I suddenly thought of something, but I don't know, I came to take the time to think. A hint can be prompted. Thank you, sir.
Specific about the implementation part of the code is not posted here. Baidu Quick sort on can.
Quick Sort (Quicksort)