Quick Sort Method QuickSort---Java

Source: Internet
Author: User

Quick Sort Method:

public class Main {public static void Main (string[] args) {int a[]={7,8,1,3,5};    New Main (a);         Public Main (int[] a) {System.out.println ("before sorting:");         Print (a);         QuickSort (a,0,a.length-1);         System.out.println ();         System.out.println ("After sorting:");     Print (a); } public int Getmiddle (int[] list,int low,int high) {int temp=list[low];//array first as the middle axis while (LOW&L                T;high) {while (Low < high && list[high]>=temp) high--;                The number of list[low]=list[high];//is smaller than the middle axis and moved to the low side while (lower < high && list[low]<=temp) low++; The list[high]=list[low];//is larger than the middle axis and moves to the high end of the list[low]=temp;//axis recorded to the tail//SYSTEM.OUT.PRINTLN ("low== High?           "+ (Low==high) +" low= "+low+" high= "+high); Return low;//returns the position of the axis//To determine that the last three axes are 3 2 0} public void QuickSort (int. a[],int Low,int High) {if (lo WThis algorithm should be done at the fingertips.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Quick Sort Method QuickSort---Java

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.