希尔排序基于插入排序
public static void shellSort(int[] nums){
for(int gap = nums.length/2; gap > 0; gap /= 2){
for(int i = gap; i< nums.length; i++){
for(int j = i; j>=gap && nums[j]<nums[j-gap];j-=gap){
int temp = nums[j];
nums[j] = nums[j-gap];
nums[j-gap] = temp;
}
}
}
}
- 时间复杂度:O(n(1.3-2))
- 空间复杂度:O(1)
- 不稳定的