Quick Sort (Quicksort)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.