希尔-冒泡排序(慢)
public void shellBubbleSort(int[] nums){
for (int step = nums.length/2; step > 0 ; step /= 2) {
for (int i = step; i < nums.length; i++) {
for (int j = i-step; j >= 0; j -= step) {
if(nums[j] > nums[j+step]){
int temp = nums[j];
nums[j] = nums[j+step];
nums[j+step] = temp;
}
}
}
}
}
希尔-插入排序(快)
public void shellInsertSort(int[] nums){
for (int step = nums.length/2; step > 0; step /= 2) {
for (int i = step; i < nums.length; i++) {
int j = i;
int insertNum = nums[i];
while(j-step >= 0 && nums[j-step] > insertNum){
nums[j] = nums[j-step];
j-=step;
}
nums[j] = insertNum;
}
}
}
PS:引入步长减少数字交换次数提高效率
上面是“java常见排序算法——希尔排序(附代码示列)”的全面内容,想了解更多关于 后端开发 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4259.html
workflows工作流
一个迷人而丰满的女巫和一只黑猫骑着飞天扫帚
一只乌鸦栖息在一盏神灯上
一只处于战斗状态下的蚂蚁ComfyUI工作流
一个女孩骑着一辆生锈的现代摩托车
一个威武雄壮的战士ComfyUI工作流
金属埃及人ComfyUI工作流
一位宇航员做在一只乌龟上在星空中游走
文生图工作流:树枝上站着一只鸟
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

纯CSS饼图效果
做一个好玩的时钟翻牌效果
黑客入侵效果代码
数字滚动效果(兼容IE6/IE8)
纯html+css做一个3d统计效果
css3+js菜单点击动态效果
javascript如何利用draggable实现一个拖拽效果
用canvas实现画板涂鸦效果







