22 건의
PROGRAMMING LANGUAGES/Java 검색결과

public void shellSort(Integer[] arr) {

		int interval = arr.length / 2;

		while (interval != 0) {
			for (int i = 0; i < interval; i++) {
				for (int p = i + interval; p < arr.length; p += interval) {
					
                    int key = arr[p];
					int j = p - interval;
					while (j >= 0) {
						if (key < arr[j]) {
							arr[j + interval] = arr[j];
						} else 
							break;
						j -= interval;
					} 
					arr[j + interval] = key;
                    
				} 
			}
			interval /= 2;
		}
}