High-speed sequencing (Java edition)

Source: Internet
Author: User

package com.love.test;import java.util.Scanner;/** * @author Huowolf * High-speed sequencing implementation * Fast-line is a very good sorting algorithm. 

* Core: Division Method (1. Select Primitives 2. Partition 3. Recursive sub-column) */public class QuickSort {public static void QuickSort (int[] arr,int start, int end) {i F (start<end) {int I=start, j=end, x=arr[start];//Primitive while (i<j) {//right-to-left scan of less than x while (I<j && arr[j]>= x) j--;if (i<j) arr[i++]=arr[j];//scan from left to right for numbers greater than x while (I<j && arr[i]<=x) i++;if (i<j) arr[j--]=arr[i];} arr[i]=x;//the base number quicksort (arr, start, end-1) in the last position;//recursive quicksort (arr, start+1, end);}} public static void Main (string[] args) {int[] arr = new int [10]; System.out.println ("Please enter 10 integers:"); Scanner s = new Scanner (system.in); for (int i=0;i<10;i++) {Arr[i] = S.nextint ();} System.out.println ("Order before sorting:"); for (int i=0;i<10;i++) {System.out.print (arr[i]+ "");} QuickSort (arr, 0, arr.length-1); System.out.println ("\ n sort order:"); for (int i=0;i<10;i++) {System.out.print (arr[i]+ "")}}}

Take a visit to a Daniel's blog, very good, blog address: http://blog.csdn.net/morewindows/article/details/6684558

Come on, yourself!!

High-speed sequencing (Java edition)

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.