Hill sorting algorithm

Shell sort

Idea: graphic
Here Insert Picture Description

Code:

public static void shellSort(int[] a){
		int n = a.length;
		for(int h = n/ 2; h > 0; h /= 2){
			for(int i = h; i < n; i++){
				for(int j = i; j >= h ; j -= h){
					if(a[j] < a[j - h]){
						int temp = a[j];
						a[j] = a[j-h];
						a[j-h] = temp;
					}
				}
			}
		}		
	}
							***帅气的远远啊***
Published 32 original articles · won praise 19 · views 3002

Guess you like

Origin blog.csdn.net/qq_41585840/article/details/104076589