Graphical Sorting Algorithm Quick Sort-Single-Ended Probe

Quick sort is an improved version of bubble sort, and it is also the best internal sort. It appears in many interview questions, and it is also a sorting method that programmers must master.

Ideas: 1. Take any element as the benchmark in the elements to be sorted (usually the first element is selected, but the best selection method is to randomly select one of the elements to be sorted as the benchmark), which is called the benchmark element;

       2. Divide the elements to be sorted, and put the elements larger than the reference element on the right side of the element, and place the elements smaller than it on the left side;

       3. Repeat the above steps for the left and right partitions until all elements are ordered.

So I think of quick sort as East-to-West or East-to-West, and to make up while removing, until all elements are in an orderly state.

Let’s take a look at the diagram below to understand:

                                  

 

                                  

6. Repeat the above operation for the elements on both sides of element 5 until the elements reach an ordered state.

Algorithm implementation:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325940322&siteId=291194637