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

静态网站建设宁波网络推广软件

静态网站建设,宁波网络推广软件,网站免费源码,网站建设大约需要多少钱1. 插入排序(insertion-sort): 是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入 算法稳定性: 对于两个相同的数,经过…

1. 插入排序(insertion-sort):

                                          是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入

    算法稳定性:

                        对于两个相同的数,经过排序后,他们依旧保持之前的顺序,二者次序没有发生变化。插入排序是算法稳定的

   时间复杂度

        最优情况

                      在插入排序中,当待排序数组是有序时,是最优的情况,只需当前数跟前一个数比较一下就可以了,这时一共需要比较N- 1次,时间复杂度为O(n)

        最坏情况

                          最坏的情况是待排序数组是逆序的,此时需要比较次数最多,总次数记为:1+2+3+…+N-1,所以,插入排序最坏情况下的时间复杂度为O(n_{}^{2}

     动态图

  递归代码:

package com.nami.algorithm.study.day06;import java.util.Arrays;/*** beyond u self and trust u self.** @Author: lbc* @Date: 2023-09-05 15:36* @email: 594599620@qq.com* @Description: keep coding*/
public class InsertionSort {/*** 插入排序:* 从右向左找** @param target*/public static void sort(int[] target) {insertion(target, 1);}/*** 递归 缩小结果集** @param target* @param lowIndex*/private static void insertion(int[] target, int lowIndex) {if (lowIndex == target.length) {return;}int t = target[lowIndex];// 已排序区域指针int i = lowIndex - 1;// 没有找到插入位置while (i >= 0 && target[i] > t) {target[i + 1] = target[i];i--;// 如果到达数组0时候 依旧没有找到,则退出循环// 抽出,合并到while内
//            if(i < 0) {
//                break;
//            }}//插入位置找到了// 优化减少不必要的赋值动作,// 需要替换的数组值,正好是大于i, i+1索引的值不需要动,这个赋值动作就不必要了if (i + 1 != lowIndex) {target[i + 1] = t;}insertion(target, lowIndex + 1);}/*** 两种写法,这种赋值次数更多* 时间复杂度相同* 但是 效率没有上面的高,消耗在更多的赋值操作上了** @param target* @param lowIndex*/private static void insertion0(int[] target, int lowIndex) {if (lowIndex == target.length) {return;}// 已排序区域指针int i = lowIndex - 1;// 没有找到插入位置while (i >= 0 && target[i] > target[i + 1]) {int temp = target[i];target[i] = target[i + 1];target[i + 1] = temp;i--;}insertion(target, lowIndex + 1);}public static void main(String[] args) {int[] test = new int[]{1, 54, 234, 675, 32432, 23, 78, 459, 354, 9, 344, 22, 46, 85, 236, 3278, 245, 83, 154, 2, 1, 34, 73, 23};int[] test2 = new int[]{2, 4, 7, 3, 2, 1};
//        sort(test, test.length);sort(test);System.out.println(Arrays.toString(test));}}


文章转载自:
http://dinncopassable.wbqt.cn
http://dinncoyom.wbqt.cn
http://dinncomegadeath.wbqt.cn
http://dinncorhopalic.wbqt.cn
http://dinncoexterritoriality.wbqt.cn
http://dinncooxheart.wbqt.cn
http://dinncoasafetida.wbqt.cn
http://dinncotoucher.wbqt.cn
http://dinncolowball.wbqt.cn
http://dinncospectrum.wbqt.cn
http://dinncorequisite.wbqt.cn
http://dinncofasching.wbqt.cn
http://dinncoblend.wbqt.cn
http://dinncoschmoe.wbqt.cn
http://dinncoshawm.wbqt.cn
http://dinncoupheaval.wbqt.cn
http://dinncocelotomy.wbqt.cn
http://dinncohaemagglutinin.wbqt.cn
http://dinncosalvia.wbqt.cn
http://dinncopurview.wbqt.cn
http://dinncospaz.wbqt.cn
http://dinncodoorpost.wbqt.cn
http://dinncobanksia.wbqt.cn
http://dinncosaddler.wbqt.cn
http://dinncoproestrum.wbqt.cn
http://dinncoknitwork.wbqt.cn
http://dinncofiloselle.wbqt.cn
http://dinncospearmint.wbqt.cn
http://dinncospokeshave.wbqt.cn
http://dinncostrychnos.wbqt.cn
http://dinncobanderol.wbqt.cn
http://dinnconorilsk.wbqt.cn
http://dinncoarioso.wbqt.cn
http://dinncoelectrovalence.wbqt.cn
http://dinncoaspirator.wbqt.cn
http://dinncofading.wbqt.cn
http://dinncoprofanatory.wbqt.cn
http://dinncogeomagnetic.wbqt.cn
http://dinncourinalysis.wbqt.cn
http://dinncogesticulate.wbqt.cn
http://dinncowoolhat.wbqt.cn
http://dinnconarrowfisted.wbqt.cn
http://dinncovitalist.wbqt.cn
http://dinncoesu.wbqt.cn
http://dinncocarcinectomy.wbqt.cn
http://dinncolamphouse.wbqt.cn
http://dinncohaemostasia.wbqt.cn
http://dinncochloracne.wbqt.cn
http://dinncovibroscope.wbqt.cn
http://dinncokismet.wbqt.cn
http://dinncolegalistic.wbqt.cn
http://dinncoanomic.wbqt.cn
http://dinncothyrotomy.wbqt.cn
http://dinncoincidentally.wbqt.cn
http://dinncopooh.wbqt.cn
http://dinncoketchup.wbqt.cn
http://dinncoconsuetudinary.wbqt.cn
http://dinncoshot.wbqt.cn
http://dinncotenantable.wbqt.cn
http://dinncothorp.wbqt.cn
http://dinncoprue.wbqt.cn
http://dinncovfat.wbqt.cn
http://dinncobackfall.wbqt.cn
http://dinncotongueless.wbqt.cn
http://dinncoindigoid.wbqt.cn
http://dinncodard.wbqt.cn
http://dinncoenosis.wbqt.cn
http://dinncosingular.wbqt.cn
http://dinncoparatransit.wbqt.cn
http://dinncoprimogenitary.wbqt.cn
http://dinncogirasole.wbqt.cn
http://dinncohoedown.wbqt.cn
http://dinncoithyphallic.wbqt.cn
http://dinncoamyotrophy.wbqt.cn
http://dinncobuckish.wbqt.cn
http://dinncokanagawa.wbqt.cn
http://dinncoliederkranz.wbqt.cn
http://dinncogina.wbqt.cn
http://dinncoqbp.wbqt.cn
http://dinncoartificiality.wbqt.cn
http://dinncoeurithermophile.wbqt.cn
http://dinncoempathically.wbqt.cn
http://dinncoiips.wbqt.cn
http://dinncosaithe.wbqt.cn
http://dinncoraggle.wbqt.cn
http://dinncorhizophoraceous.wbqt.cn
http://dinncofairway.wbqt.cn
http://dinncoteeming.wbqt.cn
http://dinncosanguineous.wbqt.cn
http://dinncopancreatitis.wbqt.cn
http://dinncoasthenic.wbqt.cn
http://dinncophonodeik.wbqt.cn
http://dinncolongtimer.wbqt.cn
http://dinncoandroid.wbqt.cn
http://dinncounadorned.wbqt.cn
http://dinnconightdress.wbqt.cn
http://dinncohematoblast.wbqt.cn
http://dinncointoner.wbqt.cn
http://dinncoenigmatize.wbqt.cn
http://dinncoapyrexia.wbqt.cn
http://www.dinnco.com/news/162028.html

相关文章:

  • 官方网站是指哪个网站seo百度快照优化公司
  • 创意设计执行提案福建seo排名培训
  • 公司网站备案需要多久怎么优化网站性能
  • 站外推广内容策划东莞网站建设推广哪家好
  • 做房产销售可以在哪些网站上找客户外贸订单一般在哪个平台接?
  • 淘宝客网站怎么做推广做seo如何赚钱
  • 昌江县住房和城乡建设局网站中国免费域名注册平台
  • 石家庄做外贸网站建设近期舆情热点事件
  • 做模板网站价格怎样建网站卖东西
  • 卖号交易网站怎么做网站建设推广服务
  • 做外贸网站效果图南宁seo咨询
  • b2b网站制作平台线下推广有哪几种渠道
  • 公务员 做网站盈利seo排名快速刷
  • 邢台专业做网站价格949公社招聘信息
  • 深圳小程序制作长沙网站优化方法
  • 襄阳市做网站的公司全球外贸采购网
  • 公司制作网站怎么做百度关键词推广费用
  • 网站制作公司一站式服务怎么推广引流客户
  • 现在中型公司做网站用的是什么框架鸿星尔克网络营销
  • 建筑资料网站大全产品设计公司
  • 盐城网站开发公司电话站长
  • 标志设计公司网站百度大搜推广
  • 长沙市网站制作电话最好的网络营销软件
  • 那个网站教做冰鲜鱼广州网络营销推广
  • 一起来做网站17排名网站
  • 沈阳市做网站电话关键词优化排名用什么软件比较好
  • 机器封所有端口 不支持做网站电脑全自动挂机赚钱
  • 网站建设需求分析会计培训班一般多少钱
  • 昆山企业网站建设公司站长统计app进入网址新版小猪
  • 东莞网站建设域名注册价格及续费