Sorting methods--Quick sort

Source: Internet
Author: User

Recently there's a front-end big God wrote the wrong fast sort, so I'm here to record

The so-called quick sort is divided by the Order of the Division of the continuous recursive array into two parts of the size, and then continue to be divided into two parts of the size

The entire array is ordered in the process of splitting.

More exchange times, fewer iterations, less space

The code is as follows

     Public Static voidFastsort (int[] arr,intLowintHigh ) {        intL=Low ; intH=High ; intp=Arr[low];  while(l<h) {             while(lp) H--; if(l<h) {                inttemp=Arr[h]; ARR[H]=Arr[l]; ARR[L]=temp; L++; }                         while(lp) L++; if(l<h) {                inttemp=Arr[h]; ARR[H]=Arr[l]; ARR[L]=temp; H--; }        }        if(L>low) Fastsort (arr,low,l-1); if(H, high); }

Sorting methods--Quick sort

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.