Java Hill sorting

Source: Internet
Author: User

Java Hill sorting

In the previous articleC ++, C #, java Algorithm learning diary 05Java cannot be started due to a problem with the computer. I will add this article:

Java example of hill sorting:
Package Sort; import java. util. *; public class Sort5 {public void ShellSort (List

 
  
Array) {int Length = array. size (); // get the Length int step = Length/2; int temp, I, j; long time_start = System. currentTimeMillis (); // start time while (step> = 1) {for (I = step; I

  
   
= 0 & temp array = new ArrayList

   
    
(); // Generate 10000 random numbers for (int I = 1; I <10000; I ++) {array. add (new Random (). nextInt (100000);} Sort5 sorter = new Sort5 (); // Hill sort sorter. shellSort (array );}}

   

  

 


Result:

 

 

 

There is also an error in the C # instance code in the previous article, int Length = array. count/2; (I was curious at the time, why was the result so short that it was half out of the original) changed to int Length = array. count; that's all. The result is similar to that of C ++.

 

 

 

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.