Problems with quick sorting

Source: Internet
Author: User

Yesterday I looked at the quick sorting, "algorithm" this book gives the realization of the sense of understanding is not very intuitive, so I combined with other books to write a fast algorithm. But there is no way to run the results, it seems that eclipse has been running, must kill the process to be able. I just learned is not very understanding, first put out the code, I hope someone can give advice.

1  PackageJava;2 3  Public classquicksort1{4     5      Public Static voidQuickSort (int[] a) {6QuickSort (A, 0, a.length-1);7     }8     Private Static voidQuickSort (int[] A,intFirstintLast ) {9         if(First <Last ) {     Ten             intPivotindex =partition (A, first, last); OneQuickSort (A, first, pivotIndex-1); AQuickSort (A, Pivotindex + 1, last); -         } -     } the      -     Private Static intPartitionint[] A,intFirstintLast ) { -      -         intLow = first + 1; +         intHigh =Last ; -         intPivot =A[first]; +          A          while(true){ at              while(A[low] <= pivot && Low <Last ); -low++; -              while(A[high] >= pivot && High >First ); -high--; -             if(Low >=High ) -                  Break; in             inttemp =A[low]; -A[low] =A[high]; toA[high] =temp; +         } -A[first] =A[high]; theA[high] =pivot; *         returnHigh ; $     }Panax Notoginseng      -     Private Static voidShowint[] a) { the          for(inti = 0; i < a.length; i++) +System.out.print (A[i] + ""); A System.out.println (); the     } +      -      Public Static voidMain (string[] args) { $         int[] A ={30, 1, 23, 232, 7, 10, 90, 17, 8}; $ QuickSort (a); - Show (a); -     } the}

Problems with quick sorting

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: 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.