Java implementation of quick sorting algorithm

1. Algorithm concept.

Quicksort is an improvement of bubble sort. It was proposed by C. A. R. Hoare in 1962. 2. Algorithm idea.

Through one-time sorting, the data to be sorted is divided into two independent parts. All data in one part is smaller than all data in the other part, and then the two parts of data are sorted quickly according to this method. The whole sorting process can be recursive, so that the whole data becomes an ordered sequence.

3. Implementation ideas.

① Taking the first keyword K 1 as the control word, divide [K 1, K 2,..., k n] into two sub areas, so that all keywords in the left area are less than or equal to K 1, and all keywords in the right area are greater than or equal to K 1. Finally, the control word occupies an appropriate position in the middle of the two sub areas. In the sub area, the data is still in disorder. ② Take the left area as a whole and process it with the steps of ①, and the right area performs the same process. (i.e. recursion) ③ repeat steps ① and ② until the left area is processed.

Schematic diagram of quick sort algorithm:

The above is the whole content of this article. I hope it will be helpful for you to learn java quick sorting algorithm.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>