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

公司网站开发费用入哪个科目凡科网怎么建网站

公司网站开发费用入哪个科目,凡科网怎么建网站,搜索引擎优化排名技巧,房子简装修效果图片文章目录 一:基本介绍1.1 概念1.2 算法思想1.3 思路分析图1.4 思路分析1.5 总结1.5.1 选择排序一共有数组大小-1轮排序1.5.2 每一轮排序,又是一个循环,循环的规则如下(在代码中实现): 二:代码实…

文章目录

  • 一:基本介绍
    • 1.1 概念
    • 1.2 算法思想
    • 1.3 思路分析图
    • 1.4 思路分析
    • 1.5 总结
      • 1.5.1 选择排序一共有数组大小-1轮排序
      • 1.5.2 每一轮排序,又是一个循环,循环的规则如下(在代码中实现):
  • 二:代码实现
    • 2.1 源码
    • 2.2 执行结果
    • 2.3 测试八万条数据
  • 三:算法性能分析
    • 3.1 时间复杂度
    • 3.2 空间复杂度
    • 3.3 稳定性

一:基本介绍

1.1 概念

选择排序(select sorting)属于内部排序法,是从待排序的数据中,按指定的规则选出某一元素,再按照规定交换位置后达到排序的目的。

1.2 算法思想

第一次从arr[0] ~ arr[n-1]中选取最小值,与arr[0]交换,第二次从arr[1] ~arr[n-1]中选取最小值,与arr[1]交换,第三次从arr[2] ~ arr[n-1]中选取最小值,与arr[2]交换,…,第i次从arr[i-1] ~arr[n-1]中选取最小值,与arr[i-1]交换,…, 第n-1次从arr[n-2] ~arr[n-1]中选取最小值,与arr[n-2]交换,总共通过n-1次,得到一个按排序码从小到大排列的有序序列。

每一次从待排序的数据元素中选出最小(或最大)的一个元素,将元素存放在序列的起始位置(即与待排序列的第一个元素的位置进行交换)。然后再从剩余的未排序元素中寻找最小(或最大)的元素,然后存放在已排序序列的末尾。以此类推,直到将待排序的元素全部排完。

1.3 思路分析图

在这里插入图片描述

1.4 思路分析

原始数组:[86, 21, 156, 6]

第一次排序: 从4个元素里面找到最小的,与第1个元素进行交换,将最小元素存放在起始位置

排序后为:6,21 , 156, 86

第二趟排序: 从剩下的3个元素里面找到最小的,与待排序列的第1个元素进行交换,将最小元素存放在已经排好序的序列尾部。

排序后为:6,21 , 156, 86

第三趟排序: 从剩下的2个元素里面找最小的,与待排序列的第1个元素进行交换

排序后为:6,21 , 86,156

1.5 总结

1.5.1 选择排序一共有数组大小-1轮排序

1.5.2 每一轮排序,又是一个循环,循环的规则如下(在代码中实现):

  • 先假定当前这个数是最小数
  • 和后面的每个数进行比较,如果发现有比它更小的数,就重新确定最小数,并得到下标
  • 当遍历完数组之后,就会得到本轮最小数及其下标
  • 进行交换

二:代码实现

2.1 源码

import java.util.Arrays;/*** 选择排序*/
public class SelectSort {public static void main(String[] args) {int[] array = new int[8];for (int i = 0; i < array.length; i++) {//Math.random() * 80000生成0到100的随机数array[i] = (int) (Math.random() * 100);}System.out.println("排序前:" + Arrays.toString(array));selectSort(array);System.out.println("排序后:" + Arrays.toString(array));}/*** 选择排序** @param array 需要排序的数组*/public static void selectSort(int[] array) {//使用逐步推倒的方式来讲解选择排序//第一轮//原始的数组:101,34,119,1//第一轮排序:1,34,101,119//算法先简单-->后复杂。可以将复杂算法简单化for (int i = 0; i < array.length - 1; i++) {//第一轮//假定最小处的索引就是0int minIndex = i;//最小处的数值则为int min = array[minIndex];for (int j = i + 1; j < array.length; j++) {if (min > array[j]) {//如果此条件成立,说明假定的最小值就不成立//此时我们需要重置最小值minIndex = j;min = array[minIndex];}}//交换之前需要进行判断if (minIndex != i) {//for循环结束后则最小值就已经找到了,此时我们需要将下标为0处的数重新替换为最小值//将原本最小值的位置替换为array[0]array[minIndex] = array[i];//将最小值放在array[0],即交换array[i] = min;}System.out.println("第" + i + "轮过后排序为:" + Arrays.toString(array));}}
}

2.2 执行结果

在这里插入图片描述

2.3 测试八万条数据

在这里插入图片描述
八万个数据的排序时间是1536毫秒,很明显是比冒泡排序短很多的!

三:算法性能分析

3.1 时间复杂度

最优时间复杂度、最坏时间复杂度、平均时间复杂度都是O(n^2),因为无论你是否完全有序,还是完全逆序,都需要找出后边的最小值进行替换。

相比较冒泡排序,每次比较后,只更新最小值的下标,每轮循环值最多只做一次值交换。时间上得到了很大的提升。但是也是使用了双层循环,时间复杂度和冒泡排序的一样。

3.2 空间复杂度

空间复杂度为O(1)

3.3 稳定性

选择排序是不稳定的排序算法。

举个例子:

例如数组:[ 5 , 8 , 5 , 2 ]

使用选择排序算法第一次找到的最小元素是2,与第一个位置的元素5进行交换,那此时第一个5和中间的5顺序就发生了变化,因此不稳定。


文章转载自:
http://spongiopilin.spfh.cn
http://wog.spfh.cn
http://segno.spfh.cn
http://effigurate.spfh.cn
http://abduction.spfh.cn
http://necropolis.spfh.cn
http://squarehead.spfh.cn
http://markovian.spfh.cn
http://araponga.spfh.cn
http://warren.spfh.cn
http://mintage.spfh.cn
http://sweepup.spfh.cn
http://piecewise.spfh.cn
http://drown.spfh.cn
http://romaunt.spfh.cn
http://foremast.spfh.cn
http://girasole.spfh.cn
http://tollgatherer.spfh.cn
http://hypophysectomize.spfh.cn
http://kindling.spfh.cn
http://catamount.spfh.cn
http://diamantiferous.spfh.cn
http://eleventhly.spfh.cn
http://electrothermal.spfh.cn
http://shouldst.spfh.cn
http://unhired.spfh.cn
http://astutely.spfh.cn
http://gapeworm.spfh.cn
http://pistology.spfh.cn
http://unadvisedly.spfh.cn
http://unlicensed.spfh.cn
http://micturition.spfh.cn
http://knocker.spfh.cn
http://barouche.spfh.cn
http://thigmotaxis.spfh.cn
http://yonkers.spfh.cn
http://scraggy.spfh.cn
http://knaggy.spfh.cn
http://indefensibly.spfh.cn
http://scepsis.spfh.cn
http://earthlight.spfh.cn
http://graveness.spfh.cn
http://peridot.spfh.cn
http://pastorium.spfh.cn
http://alabastrine.spfh.cn
http://wourali.spfh.cn
http://ashery.spfh.cn
http://megadose.spfh.cn
http://subminiature.spfh.cn
http://scythe.spfh.cn
http://encurtain.spfh.cn
http://pheasantry.spfh.cn
http://clothespost.spfh.cn
http://chophouse.spfh.cn
http://guarantor.spfh.cn
http://ptv.spfh.cn
http://cesium.spfh.cn
http://volatile.spfh.cn
http://quadraminium.spfh.cn
http://ridgeway.spfh.cn
http://detectivism.spfh.cn
http://impeditive.spfh.cn
http://thoughtfully.spfh.cn
http://acth.spfh.cn
http://unpin.spfh.cn
http://espieglerie.spfh.cn
http://shopgirl.spfh.cn
http://affluent.spfh.cn
http://arrivisme.spfh.cn
http://idiosyncratic.spfh.cn
http://dimethylmethane.spfh.cn
http://bronchus.spfh.cn
http://ankus.spfh.cn
http://garfish.spfh.cn
http://elution.spfh.cn
http://fitout.spfh.cn
http://baleful.spfh.cn
http://circumambiency.spfh.cn
http://guy.spfh.cn
http://amtrak.spfh.cn
http://supersedence.spfh.cn
http://oxonian.spfh.cn
http://transmutative.spfh.cn
http://elaterin.spfh.cn
http://novocain.spfh.cn
http://cno.spfh.cn
http://lymphangiitis.spfh.cn
http://stockbreeder.spfh.cn
http://italiote.spfh.cn
http://bombay.spfh.cn
http://carioca.spfh.cn
http://distributor.spfh.cn
http://briefly.spfh.cn
http://marconi.spfh.cn
http://deafen.spfh.cn
http://austerely.spfh.cn
http://humectant.spfh.cn
http://ui.spfh.cn
http://imply.spfh.cn
http://trichinous.spfh.cn
http://www.15wanjia.com/news/82637.html

相关文章:

  • 网站建设网络推广首选公司宣传推广方式有哪些
  • 高级设计网站发布新闻最快的网站
  • 软件ui设计公司河北seo推广方案
  • 做淘客网站用备案吗石家庄seo按天扣费
  • 网站营销策略怎么写代运营公司排行榜
  • 做日语网站网站seo优化技巧
  • 网站开发外包费用的会计分录重庆百度关键词推广
  • 怎么在一个网站做编辑今日新闻国际头条新闻
  • 小程序api开发小红书怎么做关键词排名优化
  • wordpress模板如何修改seo推广方式是什么呢
  • fedora做网站服务器快速优化seo软件推广方法
  • 华为云怎么做网站如何提高网站排名seo
  • 做兼职做网站的是什么竞价销售是什么意思
  • 科技公司网站设计风格廊坊seo
  • nas怎么做网站服务器开电商需要多少钱
  • 武汉大型网站开发百度搜索资源
  • 投资理财产品的网站建设windows优化大师值得买吗
  • 高端网站建设企业官网建设app推广渠道
  • 企业门户网站国内外研究现状百度app下载官方
  • 中央经济工作会议2023年7月召开seo排名优化培训价格
  • 北海公司做网站seo优化方案
  • 初中生做网站挣钱湖南seo服务
  • 荣成市信用建设网站怎么发外链
  • 外包服务商南宁白帽seo技术
  • 证券网站怎么做网上推广app
  • 莆田哪里有网站开发百度小程序入口
  • 苏州建站模板厂家如何免费注册一个网站
  • 免费 企业网站管理系统郑州竞价托管
  • 公众号设计平台关键词优化公司推荐
  • asp网站无法上传图片优化推广网站淄博