希尔-冒泡排序(慢)
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工作流
1个黑发带着耳机项链的女孩ComfyUI工作流
小鸟在黑暗的天空中优雅地跳舞
泰坦尼克号桌面壁纸上ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

HTML5 Canvas 刻度尺
用ascii字符画图像
js导出excel插件(兼容mac电脑Numbers表格)
做一个好玩的时钟翻牌效果
SVG路径动画效果
如何利用css3+js做一个下雨效果
js实现下雪特效
css3动画loading效果










