希尔-冒泡排序(慢)
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工作流
一个闪闪发光的金属球ComfyUI工作流
一张科幻照片,火星车在沙漠里ComfyUI工作流
在白雪覆盖的广阔平原上两只可爱的小猫
潜水员,珊瑚,鲸鱼,潜水艇comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用css绘画棋盘布局(象棋)
利用css3做一个动态loading效果
利用js+css3做一个小鱼游泳特效
3d空间行走效果
3D立体人物效果
用svg画出游泳池动画效果
js实现下雪特效
纯html+css做一个3d统计效果







