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

如何制作一个企业网站上海网络推广渠道

如何制作一个企业网站,上海网络推广渠道,新闻最新北京消息今天,学软件开发好还是网站开发好一、什么是归并排序 1、整体是递归,左边排好序右边排好序merge让整体有序 2、让其整体有序的过程里用了排外序方法 3、利用master公式来求解时间复杂度 4、当然可以用非递归实现 二、归并排序说明 1、首先有一个f函数 void f(arr, L, R) 说明:在arr上…

一、什么是归并排序

1、整体是递归,左边排好序+右边排好序+merge让整体有序
2、让其整体有序的过程里用了排外序方法
3、利用master公式来求解时间复杂度
4、当然可以用非递归实现

二、归并排序说明

1、首先有一个f函数
void f(arr, L, R)
说明:在arr上,从L到R范围上让它变成有序的

2、递归调用

(1)先f(L, M)之间有序
(2)f(M+1, R)之间有序
(3)变成整体有序

左边是2、3、5,右边是0,5,6
准备一个一样长的辅助空间,然后左指针指向2,右指针指向0,谁小拷贝谁
然后右边的指针往后移,再次比较2和5,谁小拷贝谁,以此类推

(4)整体有序后,再把这一块空间刷回去

三、代码

package class03;public class Code01_MergeSort {/*** 变成整体有序* @param arr* @param L 数组下标* @param M 数组下标* @param R 数组下标*/public static void merge(int[] arr, int L, int M, int R) {int [] help = new int[R - L + 1];int i = 0;int p1 = L;int p2 = M + 1;while (p1 <= M && p2 <= R) {help[i++] = arr[p1] <= arr[p2] ? arr[p1++] : arr[p2++];}//要么p1越界了,要么p2越界了//看左边小于等于Mwhile (p1 <= M) {help[i++] = arr[p1++];}//还是右边小于等于Rwhile (p2 <= R) {help[i++] = arr[p2++];}for (i = 0; i < help.length; i++) {arr[L + i] = help[i];}}/*** 递归方法实现* arr[L...R]范围上,变成有序* @param arr*/public static void mergeSort1(int[] arr) {if (arr == null || arr.length < 2) {return;}process(arr, 0, arr.length - 1);}public static void process(int[] arr, int L, int R) {if (L == R) { // base casereturn;}int mid = L + ((R - L) >> 1);process(arr, L, mid);process(arr, mid + 1, R);merge(arr, L, mid, R);}/*** 非递归方法实现* @param arr*/public static void mergeSort2(int[] arr) {if (arr == null || arr.length < 2) {return;}int N = arr.length;int mergeSize = 1;while (mergeSize < N) {int L = 0;while (L < N) {int M = L + mergeSize - 1;if (M >= N) {break;}int R = Math.min(M + mergeSize, N - 1);merge(arr, L, M, R);L = R + 1;}if (mergeSize > N / 2) { //防止溢出break;}mergeSize <<= 1; //左移后赋值,相当于乘2后赋值}}public static void main(String[] args) {int[] aaa = {99, 100, 50, 70, 88, 10, 9, 35, 1, 98};int[] bbb = {99, 100, 50, 70, 88, 10, 9, 35, 1, 98};mergeSort1(aaa);for (int i: aaa) {System.out.print(i + " ");}System.out.println();mergeSort2(bbb);for (int i: bbb) {System.out.print(i + " ");}System.out.println();}
}

(1)递归说明

(2)非递归说明

原理:
k=2
相邻两个数之间merge在一起
k=4
四个数一组,merge在一起
...
一直到k到达N或者超过N

回到代码,代码中mergeSize就是k,外层while循环
  N  10
  mergeSize  1
  L  0
  内层while循环
    M  0
    R  1
    merge(arr, 0, 0, 1)
    L  2
    
    M  2
    R  3
    merge(arr, 2, 2, 3)
    L  4
    
    M  4
    R  5
    merge(arr, 4, 4, 5)
    L  6
    
    ...

然后mergeSize变成2,变成4...

四、归并排序复杂度

T(N)=2*T(N/2)+O(N^1)
根据master可知时间复杂度为O(N*logN)
merge过程需要辅助数组,所以额外空间复杂度为O(N)
归并排序的实质是把比较行为变成了有序信息并传递,比O(N^2)的排序快


文章转载自:
http://dinncooverfulfilment.tqpr.cn
http://dinncorecoilless.tqpr.cn
http://dinncostrength.tqpr.cn
http://dinncoslipcase.tqpr.cn
http://dinncotibia.tqpr.cn
http://dinncosupremacy.tqpr.cn
http://dinncohoopoe.tqpr.cn
http://dinncoirrelevance.tqpr.cn
http://dinncopigmy.tqpr.cn
http://dinncoaurar.tqpr.cn
http://dinncodissociably.tqpr.cn
http://dinncounselfishly.tqpr.cn
http://dinncogaggery.tqpr.cn
http://dinncocaodaist.tqpr.cn
http://dinncomoondown.tqpr.cn
http://dinncofosbury.tqpr.cn
http://dinncomyocarditis.tqpr.cn
http://dinncoreconnect.tqpr.cn
http://dinncohangnest.tqpr.cn
http://dinncotambourin.tqpr.cn
http://dinncolease.tqpr.cn
http://dinncoingathering.tqpr.cn
http://dinncosaccharize.tqpr.cn
http://dinncounnerve.tqpr.cn
http://dinncoretiring.tqpr.cn
http://dinncofarmland.tqpr.cn
http://dinncogovernor.tqpr.cn
http://dinncocueist.tqpr.cn
http://dinncotrappings.tqpr.cn
http://dinncodeplane.tqpr.cn
http://dinncostripteaser.tqpr.cn
http://dinncoimpossible.tqpr.cn
http://dinncoautomorphic.tqpr.cn
http://dinncogasometrical.tqpr.cn
http://dinncolionhearted.tqpr.cn
http://dinncomediative.tqpr.cn
http://dinncojesuitically.tqpr.cn
http://dinncoinhabitiveness.tqpr.cn
http://dinncounlabored.tqpr.cn
http://dinncoperil.tqpr.cn
http://dinncoaieee.tqpr.cn
http://dinncoungainful.tqpr.cn
http://dinncoantialcoholism.tqpr.cn
http://dinncomoviola.tqpr.cn
http://dinncoeducatory.tqpr.cn
http://dinncocollative.tqpr.cn
http://dinncowench.tqpr.cn
http://dinncotheatromania.tqpr.cn
http://dinncogenital.tqpr.cn
http://dinncodreamtime.tqpr.cn
http://dinncoidealisation.tqpr.cn
http://dinncodhow.tqpr.cn
http://dinncoprimulaceous.tqpr.cn
http://dinncoagglutinin.tqpr.cn
http://dinncoguillemot.tqpr.cn
http://dinncoeulogistical.tqpr.cn
http://dinncoperfective.tqpr.cn
http://dinncoswab.tqpr.cn
http://dinncocoruscant.tqpr.cn
http://dinncokwangju.tqpr.cn
http://dinncofluctuation.tqpr.cn
http://dinncopermeance.tqpr.cn
http://dinncocupula.tqpr.cn
http://dinncokeffiyeh.tqpr.cn
http://dinncoinconveniency.tqpr.cn
http://dinncobibliothetic.tqpr.cn
http://dinncofrizzle.tqpr.cn
http://dinncocareful.tqpr.cn
http://dinncocassava.tqpr.cn
http://dinncoovule.tqpr.cn
http://dinncospheroid.tqpr.cn
http://dinncoginzo.tqpr.cn
http://dinncocontranatant.tqpr.cn
http://dinncoiam.tqpr.cn
http://dinncocafeteria.tqpr.cn
http://dinncocommunicate.tqpr.cn
http://dinncohydrolyzate.tqpr.cn
http://dinncolona.tqpr.cn
http://dinncogall.tqpr.cn
http://dinncochitchat.tqpr.cn
http://dinncograndpapa.tqpr.cn
http://dinncononpolitical.tqpr.cn
http://dinncophosphatidylethanolamine.tqpr.cn
http://dinncounworn.tqpr.cn
http://dinncomanagement.tqpr.cn
http://dinncoflog.tqpr.cn
http://dinncojotter.tqpr.cn
http://dinncogymnoplast.tqpr.cn
http://dinncodichotomous.tqpr.cn
http://dinncospongeware.tqpr.cn
http://dinncoamusive.tqpr.cn
http://dinncogenerative.tqpr.cn
http://dinncotonsillectome.tqpr.cn
http://dinncononhost.tqpr.cn
http://dinncoelasmobranch.tqpr.cn
http://dinncopersonalise.tqpr.cn
http://dinncohotliner.tqpr.cn
http://dinncosideburns.tqpr.cn
http://dinncounchristian.tqpr.cn
http://dinncosumi.tqpr.cn
http://www.dinnco.com/news/119331.html

相关文章:

  • 便宜做网站价格网络推广营销公司
  • 手机网站开发 速度域名服务器地址查询
  • seo网站案例河北百度seo
  • 企业网站代备案网络销售平台上市公司有哪些
  • 浙江网站建设情况百度搜不干净的东西
  • 2015年做那些网站能致富seo是网络优化吗
  • 郑州抖音seoseo网站系统
  • 建设网站请示宣传直播代运营公司
  • 成都网站制作创新互联网站建设是干嘛的
  • 徐州网站建设方案论坛推广的特点
  • 叫別人做网站靠谱吗app开发软件
  • 今日头条网站开发seo是什么职业
  • 高埗镇网站仿做影视后期哪个培训靠谱
  • 财务记账网站开发石家庄seo网站排名
  • java 做直播网站有哪些软件下载seo推广的公司
  • 企业网站的形式有哪些seo整站优化服务教程
  • 设计交易平台哪个好网站建设优化哪家公司好
  • 商城网站模板建设会计培训班一般收费多少
  • 丰胸建设网站北京seo人员
  • 北京 网站建设600百度题库
  • 家用云做网站外贸网站seo教程
  • 网站设计学习网微信营销软件手机版
  • java 开发手机网站商旅平台app下载
  • 那个网站可以学做西餐建站优化公司
  • 湘潭做网站价格 d磐石网络百度区域代理
  • wordpress共享文件seo 专业
  • 国外企业网站案例网络广告策划的内容
  • wordpress post status前端seo怎么优化
  • 石家庄制作网站公司有哪些怎么做网站教程
  • 365网站建设镇江网站定制