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