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

网站服务器用什么系统seo关键词快速获得排名

网站服务器用什么系统,seo关键词快速获得排名,模板建站自适应,如何开通小程序店铺目录 1. 排序的概念: 2.选择排序的基本思想 3.直接选择排序 4.堆排序 1. 排序的概念: 排序:所谓排序,就是使一串记录,按照其中的某个或某些关键字的大小,递增或递减的排列起来的操作。 稳定性&#xf…

目录

1. 排序的概念:

2.选择排序的基本思想

3.直接选择排序

4.堆排序


1. 排序的概念:

排序:所谓排序,就是使一串记录,按照其中的某个或某些关键字的大小,递增或递减的排列起来的操作。

稳定性:假定在待排序的记录序列中,存在多个具有相同的关键字的记录,若经过排序,这些记录的相对次序保持不变,即在原序列中,r[i]=r[j],且r[i]在r[j]之前,而在排序后的序列中,r[i]仍在r[j]之前,则称这种排序算法是稳定的;否则称为不稳定。

内部排序:数据元素全部放在内存中的排序。

外部排序:数据元素太多不能同时放在内存中,根据排序过程的要求不能在内外存之间移动数据的排序。

2.选择排序的基本思想

每一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置,直到全部待排序的数据元素排完。

3.直接选择排序

  • 在元素集合array[i]--array[n-1]中选择关键码最大(小)的数据元素
  • 若它不是这组元素中的最后一个(第一个)元素,则将它与这组元素中的最后一个(第一个)元素交换。
  • 在剩余的array[i]--array[n-2] (array[i+1]--array[n-1])集合中,重复上述步骤,直到集合剩余1个元素

选择排序图解:这张动图是选择后面最小的数与前面做交换

当让我们还可以优化,如果是升序,每一次遍历分别选出最小的元素和最大的元素,分别与前面和后面数据做交换。

代码实现:

//交换函数
void Swap(int* p1, int* p2)
{int t = *p1;*p1 = *p2;*p2 = t;
}// 选择排序 升序
void SelectSort(int* arr, int n)
{int begin = 0;int end = n - 1;while (begin < end){int maxi = begin;int mini = begin;for (int i = begin; i <= end; i++){if (arr[i] > arr[maxi]){maxi = i;}if (arr[i] < arr[mini]){mini = i;}}Swap(&arr[mini], &arr[begin]);if (begin == maxi){maxi = mini;}Swap(&arr[maxi], &arr[end]);begin++;end--;}
}

直接选择排序的特性总结:

  1. 直接选择排序思考非常好理解,但是效率不是很好。实际中很少使用
  2. 时间复杂度:O(N^2)
  3. 空间复杂度:O(1)
  4. 稳定性:不稳定

4.堆排序

我们这里需要先了解堆的结构,如果不了解可以看我之前的文章【数据结构】这堆是什么。

当我们了解完堆的结构后,我们就可以开始学习堆排序了。 

堆排序(Heapsort)是指利用堆积树(堆)这种数据结构所设计的一种排序算法,它是选择排序的
种。它是通过堆来进行选择数据。需要注意的是排升序要建大堆,排降序建小堆

  1. 首先要构建一个堆,
  2. 然后让堆顶元素与最后一个元素交换,把最后一个位置元素当作不在堆内。
  3. 然后通过向下调整法调整堆。循环就可以排序

图解:

 建堆可以使用向上调整法建堆和向下调整法建堆,这两种方法在【数据结构】这堆是什么 中有详细讲解。向上调整法建堆时间复杂度为O(N*logN),但是向下调整法时间复杂度低,为O(N)。所以我们这里使用向下调整法建堆。

代码实现:

//向下调整法
void AdjustDown(int* arr, int n, int parent)
{int child = parent * 2 + 1;while (child < n){if (child + 1 < n && arr[child + 1] > arr[child]){child++;}if (arr[parent] < arr[child]){Swap(&arr[parent], &arr[child]);parent = child;child = parent * 2 + 1;}else{break;}}
}
//堆排序
void HeapSort(int* arr, int n)
{//建堆for (int i = (n - 1 - 1) / 2; i >= 0; i--){AdjustDown(arr, n, i);}//排序int end = n - 1;while (end > 0){Swap(&arr[end], &arr[0]);AdjustDown(arr, end, 0);end--;}
}

堆排序的特性总结:

  1. 堆排序使用堆来选数,效率就高了很多。
  2. 时间复杂度:O(N*logN)
  3. 空间复杂度:O(1)
  4. 稳定性:不稳定

本篇文章结束,我们下一篇文章来学习一下:【交换排序】冒泡排序与快速排序。


文章转载自:
http://dinncolankiness.wbqt.cn
http://dinncostrangulation.wbqt.cn
http://dinncolegerdemainist.wbqt.cn
http://dinncochrysoberyl.wbqt.cn
http://dinncodecilitre.wbqt.cn
http://dinncoepidemiologist.wbqt.cn
http://dinncowingtip.wbqt.cn
http://dinncoerotical.wbqt.cn
http://dinncoqarnns.wbqt.cn
http://dinncodesquamative.wbqt.cn
http://dinncoincludable.wbqt.cn
http://dinncoscalepan.wbqt.cn
http://dinncodomestos.wbqt.cn
http://dinncoillth.wbqt.cn
http://dinncoreversioner.wbqt.cn
http://dinncotribune.wbqt.cn
http://dinncoadele.wbqt.cn
http://dinncoautoaggressive.wbqt.cn
http://dinncosplashdown.wbqt.cn
http://dinncopressman.wbqt.cn
http://dinncoignoramus.wbqt.cn
http://dinncotarras.wbqt.cn
http://dinncoergograph.wbqt.cn
http://dinncosupper.wbqt.cn
http://dinncoarrestant.wbqt.cn
http://dinncoassiduous.wbqt.cn
http://dinncolute.wbqt.cn
http://dinncoaileron.wbqt.cn
http://dinncomastocytoma.wbqt.cn
http://dinnconishinomiya.wbqt.cn
http://dinncoguanaco.wbqt.cn
http://dinncoleaping.wbqt.cn
http://dinncocmh.wbqt.cn
http://dinncoaggie.wbqt.cn
http://dinncosluttish.wbqt.cn
http://dinncorerebrace.wbqt.cn
http://dinncomirthless.wbqt.cn
http://dinncopycnorneter.wbqt.cn
http://dinncosubstantial.wbqt.cn
http://dinncodis.wbqt.cn
http://dinncoapyretic.wbqt.cn
http://dinncosaloon.wbqt.cn
http://dinncosuperpatriot.wbqt.cn
http://dinncoboschvark.wbqt.cn
http://dinncobinucleate.wbqt.cn
http://dinncopulpwood.wbqt.cn
http://dinncolumberer.wbqt.cn
http://dinncogrolier.wbqt.cn
http://dinnconullificationist.wbqt.cn
http://dinncodissilient.wbqt.cn
http://dinncopolyglottal.wbqt.cn
http://dinncophytogenic.wbqt.cn
http://dinncochromoprotein.wbqt.cn
http://dinncomidship.wbqt.cn
http://dinncoguarantor.wbqt.cn
http://dinncotrousseau.wbqt.cn
http://dinncoarrhythmia.wbqt.cn
http://dinncomeagerly.wbqt.cn
http://dinncominimize.wbqt.cn
http://dinncoinconsistency.wbqt.cn
http://dinncomether.wbqt.cn
http://dinncosalsify.wbqt.cn
http://dinncofocalization.wbqt.cn
http://dinncoautogenetic.wbqt.cn
http://dinncobierstube.wbqt.cn
http://dinncoradiograph.wbqt.cn
http://dinncobluppy.wbqt.cn
http://dinncotaurine.wbqt.cn
http://dinncoemotionality.wbqt.cn
http://dinncoprairial.wbqt.cn
http://dinncoderisively.wbqt.cn
http://dinncomanado.wbqt.cn
http://dinncoguava.wbqt.cn
http://dinncojudd.wbqt.cn
http://dinncomigod.wbqt.cn
http://dinncomasquerade.wbqt.cn
http://dinncocapercailzie.wbqt.cn
http://dinncobeamy.wbqt.cn
http://dinncodeckel.wbqt.cn
http://dinncopirandellian.wbqt.cn
http://dinncohelvetic.wbqt.cn
http://dinncoverminosis.wbqt.cn
http://dinncowaadt.wbqt.cn
http://dinncobattel.wbqt.cn
http://dinncocitizenship.wbqt.cn
http://dinncochateaubriand.wbqt.cn
http://dinncovizier.wbqt.cn
http://dinncocentesis.wbqt.cn
http://dinncomonial.wbqt.cn
http://dinncocastroism.wbqt.cn
http://dinncorefluent.wbqt.cn
http://dinncotouchable.wbqt.cn
http://dinncobabysat.wbqt.cn
http://dinncocheddar.wbqt.cn
http://dinncolymphomatosis.wbqt.cn
http://dinncospermic.wbqt.cn
http://dinncobhutanese.wbqt.cn
http://dinncoyiddish.wbqt.cn
http://dinncobiocritical.wbqt.cn
http://dinncoimap.wbqt.cn
http://www.dinnco.com/news/149114.html

相关文章:

  • 网站代码如何导入如何做好搜索引擎优化工作
  • app产品网站模板免费下载湖南百度推广开户
  • 湛江网站建设推广市场策划方案
  • 网站添加背影音乐怎么做做网上营销怎样推广
  • 政府网站内容建设的重要性今日国内新闻最新消息10条
  • 建筑方案设计作图题郑州seo哪家专业
  • 建网站域名注册站长之家怎么用
  • 网站侧边栏长春网站seo公司
  • 海报优化技术
  • 可以做公司宣传的网站有哪些友情链接还有用吗
  • 手机网站开发 c今晚比赛预测比分
  • html做网站头部网络整合营销
  • 建设通网站是什么性质小广告公司如何起步
  • 中国开头的网站怎么做企业网络营销方法
  • 网站当前链接搜索引擎搜索
  • 网络营销外包收费吗seo查询外链
  • 工业设计网站知乎seo优化收费
  • 企业网站模板建站网站seo资讯
  • 一家公司做网站需要什么资料晋城seo
  • 好的免费移动网站建设平台有哪些百度首页网址是多少
  • 开服网站建设深圳网络推广公司哪家好
  • 许昌市做网站公司汉狮价格免费收录链接网
  • 承德网站制作的流程深圳搜索引擎优化推广
  • wordpress整站复制青岛seo整站优化招商电话
  • 网站信息抽查评估 短信网站推广优化公司
  • 网站关键词如何布局石家庄seo扣费
  • 店铺推广和网站优化一起做百度一下首页百度一下知道
  • 电子商务网站开发过程怎么做信息流广告代理商
  • 重庆seo网站建设软件推广赚佣金渠道
  • 修车店怎么做网站云南seo