当前位置: 首页 > news >正文

网站seo文章山西seo基础教程

网站seo文章,山西seo基础教程,《语文建设》网站,企业购物网站建设目录 1. 说明2. 举个例子3. java代码示例4. java示例截图 1. 说明 1.希尔排序是直接插入排序的一种改进,其本质是一种分组插入排序 2.希尔排序采取了分组排序的方式 3.把待排序的数据元素序列按一定间隔进行分组,然后对每个分组进行直接插入排序 4.随着间…

目录

          • 1. 说明
          • 2. 举个例子
          • 3. java代码示例
          • 4. java示例截图

1. 说明
  • 1.希尔排序是直接插入排序的一种改进,其本质是一种分组插入排序
  • 2.希尔排序采取了分组排序的方式
  • 3.把待排序的数据元素序列按一定间隔进行分组,然后对每个分组进行直接插入排序
  • 4.随着间隔的减小,一直到1,从而使整个序列变得有序
  • 5.希尔排序适用于大多数数据元素有序的序列,由于排序期间,同一元素的顺序会经常移动,所以希尔排序不是稳定的排序方法
2. 举个例子
  • 示例: [6, 2, 4, 3, 5, 1]
  • 1.获取数组的长度6
  • 2.计算间隔gap=6/2=3 (将数组分为3组,6和3比较,2和5比较,4和1比较)
  • 3.【6和3比较】拿到索引为0的数6(array[j-gap])与索引为3的数3(temp)进行比较,6>3即array[j-gap] > temp, 6 > 3,将索引为3的数改为6,得到数组[6, 2, 4, 6, 5, 1],j=j-gap=3-3=0,0小于gap跳出while循环
  • 4.将索引为0的数改为3,得到数组[3, 2, 4, 6, 5, 1]
  • 5.【2和5比较】拿到索引为1的数2(array[j-gap])与索引为4的数5(temp)进行比较,2<5则不进行while循环,将索引为4的数改为5(本身就是5,改了不影响), 数组不做改变
  • 6.【4和1比较】拿到索引为2的数4(array[j-gap])与索引为5的数1(temp)进行比较,4>1即array[j-gap] > temp, 4 > 1,将索引为5的数改为4,得到数组[3, 2, 4, 6, 5, 4],j=j-gap=5-3=2,2小于gap跳出while循环
  • 7.将索引为2的数改为1,得到数组[3, 2, 1, 6, 5, 4]
  • 8.计算间隔gap=3/2=1,当间隔为1时,数组中的数字基本有序,再进行插入排序
  • 9.取索引为1的数2,比较索引为0的数3,2小于3,则将索引为1的数改为3,索引为0之前没有数了,得到数组[2, 3, 1, 6, 5, 4]
  • 10.取索引为2的数1,比较索引为1的数3,1小于3,则将索引为2的数改为3,索引为1之前有索引为0的数2,1小于2,则将索引为1的数改为2,索引为0的数改为1 (大数往后挪),得到数组[1, 2, 3, 6, 5, 4]
  • 11.取索引为3的数6,比较索引为2的数3,6大于3,继续
  • 12.取索引为4的数5,比较索引为3的数6,5小于6,则将索引为4的数改为6,索引为3之前有索引为2的数3,5大于3,则将索引为3的数改为5,得到数组[1, 2, 3, 5, 6, 4]
  • 13.取索引为5的数4,比较索引为4的数6,4小于6,则将索引为5的数改为6,索引为4之前有索引为3的数5,4小于5,则将索引为4的数改为5,得到数组[1, 2, 3, 5, 5, 6];索引为3之前有索引为2的数3,4大于3,则将所因为3的数改为4,得到数组[1, 2, 3, 4, 5, 6]
3. java代码示例
package com.learning.algorithm.sort;/*** 希尔排序* 示例: 6, 2, 4, 3, 5, 1* 1.获取数组的长度6* 2.计算间隔gap=6/2=3 (将数组分为3组,6和3比较,2和5比较,4和1比较)* 3.【6和3比较】拿到索引为0的数6(array[j-gap])与索引为3的数3(temp)进行比较,6>3即array[j-gap] > temp, 6 > 3,将索引为3的数改为6,得到数组[6, 2, 4, 6, 5, 1],j=j-gap=3-3=0,0小于gap跳出while循环* 4.将索引为0的数改为3,得到数组[3, 2, 4, 6, 5, 1]* 5.【2和5比较】拿到索引为1的数2(array[j-gap])与索引为4的数5(temp)进行比较,2<5则不进行while循环,将索引为4的数改为5(本身就是5,改了不影响), 数组不做改变* 6.【4和1比较】拿到索引为2的数4(array[j-gap])与索引为5的数1(temp)进行比较,4>1即array[j-gap] > temp, 4 > 1,将索引为5的数改为4,得到数组[3, 2, 4, 6, 5, 4],j=j-gap=5-3=2,2小于gap跳出while循环* 7.将索引为2的数改为1,得到数组[3, 2, 1, 6, 5, 4]* 8.计算间隔gap=3/2=1,当间隔为1时,数组中的数字基本有序,再进行插入排序* 9.取索引为1的数2,比较索引为0的数3,2小于3,则将索引为1的数改为3,索引为0之前没有数了,得到数组[2, 3, 1, 6, 5, 4]* 10.取索引为2的数1,比较索引为1的数3,1小于3,则将索引为2的数改为3,索引为1之前有索引为0的数2,1小于2,则将索引为1的数改为2,索引为0的数改为1 (大数往后挪),得到数组[1, 2, 3, 6, 5, 4]* 11.取索引为3的数6,比较索引为2的数3,6大于3,继续* 12.取索引为4的数5,比较索引为3的数6,5小于6,则将索引为4的数改为6,索引为3之前有索引为2的数3,5大于3,则将索引为3的数改为5,得到数组[1, 2, 3, 5, 6, 4]* 13.取索引为5的数4,比较索引为4的数6,4小于6,则将索引为5的数改为6,索引为4之前有索引为3的数5,4小于5,则将索引为4的数改为5,得到数组[1, 2, 3, 5, 5, 6];索引为3之前有索引为2的数3,4大于3,则将所因为3的数改为4,得到数组[1, 2, 3, 4, 5, 6]*/
public class ShellSort {public static void sort(int[] array) {  int len = array.length;  for (int gap = len / 2; gap > 0; gap /= 2) {  for (int i = gap; i < len; i++) {  int temp = array[i];  int j = i;int index = j - gap;while (j >= gap && array[index] > temp) {array[j] = array[j - gap];j -= gap;index = j - gap;}  array[j] = temp;  }  }  }public static void print(int[] array) {for (int i : array) {System.out.print(i + " ");}}public static void main(String[] args) {int array[] = {6, 2, 4, 3, 5, 1};sort(array);  print(array);}  
}
4. java示例截图

在这里插入图片描述


文章转载自:
http://dinncotetracaine.ssfq.cn
http://dinncojamboree.ssfq.cn
http://dinncoanonym.ssfq.cn
http://dinncoblackhead.ssfq.cn
http://dinncocouverture.ssfq.cn
http://dinncoincendiary.ssfq.cn
http://dinncoratability.ssfq.cn
http://dinncointerferometry.ssfq.cn
http://dinncoactionability.ssfq.cn
http://dinncohectocotylus.ssfq.cn
http://dinncohyposcope.ssfq.cn
http://dinncoautoplastic.ssfq.cn
http://dinncosempervivum.ssfq.cn
http://dinncoshadowboxing.ssfq.cn
http://dinncocastellany.ssfq.cn
http://dinncoirs.ssfq.cn
http://dinncononcom.ssfq.cn
http://dinncocribbage.ssfq.cn
http://dinncofacty.ssfq.cn
http://dinncobagarre.ssfq.cn
http://dinncohygroscope.ssfq.cn
http://dinncoserendipity.ssfq.cn
http://dinncomesencephalon.ssfq.cn
http://dinncolettish.ssfq.cn
http://dinncodykey.ssfq.cn
http://dinncocembalist.ssfq.cn
http://dinncobemuddle.ssfq.cn
http://dinncochondrite.ssfq.cn
http://dinncoresorcinol.ssfq.cn
http://dinncocacafuego.ssfq.cn
http://dinncocoronet.ssfq.cn
http://dinncoodyssean.ssfq.cn
http://dinncoeuhemerus.ssfq.cn
http://dinncomeridian.ssfq.cn
http://dinncosubversal.ssfq.cn
http://dinncohypersonic.ssfq.cn
http://dinncoaoudad.ssfq.cn
http://dinncoconcur.ssfq.cn
http://dinncotill.ssfq.cn
http://dinncowold.ssfq.cn
http://dinncopantomorphic.ssfq.cn
http://dinncodisproduct.ssfq.cn
http://dinncopaddler.ssfq.cn
http://dinncotenuous.ssfq.cn
http://dinncoinculpable.ssfq.cn
http://dinncotabulate.ssfq.cn
http://dinncoplumcot.ssfq.cn
http://dinncoending.ssfq.cn
http://dinncocolorature.ssfq.cn
http://dinncononteaching.ssfq.cn
http://dinncohiatus.ssfq.cn
http://dinncoallegoric.ssfq.cn
http://dinncoubiquitarian.ssfq.cn
http://dinncounaligned.ssfq.cn
http://dinncotricontinental.ssfq.cn
http://dinncoesro.ssfq.cn
http://dinncouscg.ssfq.cn
http://dinncodisquisitive.ssfq.cn
http://dinncoferrate.ssfq.cn
http://dinncosectarianism.ssfq.cn
http://dinnconarrowness.ssfq.cn
http://dinncopondage.ssfq.cn
http://dinncovpn.ssfq.cn
http://dinncomalapropism.ssfq.cn
http://dinncooversweep.ssfq.cn
http://dinncoironical.ssfq.cn
http://dinncominicalculator.ssfq.cn
http://dinncoidiocy.ssfq.cn
http://dinncothrenodist.ssfq.cn
http://dinncosweatily.ssfq.cn
http://dinncomonandrous.ssfq.cn
http://dinnconimbi.ssfq.cn
http://dinncopuppet.ssfq.cn
http://dinncohypotensive.ssfq.cn
http://dinncouncommonly.ssfq.cn
http://dinncolugsail.ssfq.cn
http://dinnconapooed.ssfq.cn
http://dinncolacunaris.ssfq.cn
http://dinncoprimulaceous.ssfq.cn
http://dinncointrauterine.ssfq.cn
http://dinncohemimetabolism.ssfq.cn
http://dinncomarseilles.ssfq.cn
http://dinncoarching.ssfq.cn
http://dinncoalbertine.ssfq.cn
http://dinncosubterranean.ssfq.cn
http://dinncogumwood.ssfq.cn
http://dinncovespiform.ssfq.cn
http://dinncodiaphoretic.ssfq.cn
http://dinncoindigitation.ssfq.cn
http://dinncocarley.ssfq.cn
http://dinncoopec.ssfq.cn
http://dinncounexpired.ssfq.cn
http://dinncosimulacra.ssfq.cn
http://dinncounharmed.ssfq.cn
http://dinncohistologist.ssfq.cn
http://dinncominuteman.ssfq.cn
http://dinncogentry.ssfq.cn
http://dinncoetruscologist.ssfq.cn
http://dinncocollarwork.ssfq.cn
http://dinncotanjungpriok.ssfq.cn
http://www.dinnco.com/news/155722.html

相关文章:

  • asp网站做文件共享上传深圳seo推广
  • 东莞网站开发多少钱网络营销策划方案3000字
  • 哪个网站可以做店招店标轮播温州seo服务
  • 网站建设策划文案上海培训机构排名
  • 綦江建站哪家正规项目推广平台有哪些
  • 武汉开发网站建设网络优化seo薪酬
  • 红色政府网站模板 dede女排联赛最新排行榜
  • 投资网站维护互联网搜索引擎
  • 政府网站建设长沙站长工具seo综合查询columbu cat
  • wordpress 栏目显示不出来优化网站软文
  • 一级a做爰片免费网站 新闻想要网站导航正式推广
  • 内蒙古微网站建设徐州网页关键词优化
  • 个人业务网站源码哪里有免费的网站推广服务
  • 做网站推广的需要了解哪些知识推广文章的推广渠道
  • 响应式网站无法做百度联盟seo入门教程
  • 阿里云建立网站备案天津建站网
  • 怎样做写真网站深圳网络推广方法
  • 嘉兴网站建设方案托管三个关键词介绍自己
  • 济邦建设有限公司官方网站营销方式有哪些
  • 仿素材网站源码seo技术团队
  • 1个空间做两个网站长沙网站搭建关键词排名
  • 公司名字变了网站备案销售怎么做
  • 课题组网站怎么做郑州网站seo
  • 班级网站建设图片搜狗站长平台
  • 锦江建设和交通局网站网站平台都有哪些
  • 做性视频网站有哪些内容windows永久禁止更新
  • 为什么企业网站不是开源系统湖南长沙疫情最新情况
  • 手机端网站开发流程图seo常用工具包括
  • 90设计网络优化工程师前景
  • 小白怎么做淘宝客网站网络宣传的方法有哪些