The head of the Sunset Building, the voice of the hung, Jiangnan wandering. The Wu hook to see, the railing shot all over, no one will, boarding meaning.
--Deng Jiankang and Heart Pavilion
The hill algorithm is a sort algorithm proposed by Hill (D.l.shell) in 1959. is one of the first time complexity breakthrough O (N2) algorithms.
It is based on the insertion sort.
On the code:
1 Public classShellsort {2 3 Public Static voidShellsort (int[] arr) {4 5 intincrement =arr.length;6 intTemp//Card7 inti;8 intJ;9 Do {Tenincrement = increment/3+1;//Incremental One for(i = increment; i < arr.length; i++) { A if(Arr[i] < arr[i-Increment]) { -temp =Arr[i]; - for(j = i-increment; J >=0&& temp < ARR[J]; J-=increment) { theARR[J] =arr[j]^arr[j +increment]; -Arr[j + increment] =arr[j]^arr[j +increment]; -ARR[J] =arr[j]^arr[j +increment]; - } + } - } +} while(Increment >1); A } at}
Delta Pick k = 2^ (t-k+1)-1 (0≤k≤t≤?log2 (n+1)?)
Java Learning notes-sorting algorithm of hill sort (Shell sort)