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

网站是做流程b2b网站平台

网站是做流程,b2b网站平台,如何网站推广策划,科技创新绘画冒泡排序 算法步骤 不断的两两比较&#xff0c;这样当前最大的元素总是会排在最后面。所以称为冒泡。 图解算法 代码实现 public static int[] bubbleSort(int[] arr) {// i是排好了几个数for (int i 1; i < arr.length; i) {// flag标记当前循环是否调整了顺序&#xff0c…

冒泡排序

算法步骤

不断的两两比较,这样当前最大的元素总是会排在最后面。所以称为冒泡。

图解算法

在这里插入图片描述

代码实现


public static int[] bubbleSort(int[] arr) {// i是排好了几个数for (int i = 1; i < arr.length; i++) {// flag标记当前循环是否调整了顺序,如果没有调整,说明排序完成boolean flag = true;// arr.length - i控制数组尾巴for (int j = 0; j < arr.length - i; j++) {if (arr[j] > arr[j + 1]) {int tmp = arr[j];arr[j] = arr[j + 1];arr[j + 1] = tmp;flag = false;}}if (flag) {break;}}return arr;
}

算法分析

稳定性:稳定
时间复杂度:最佳: O ( n ) O(n) O(n) ,最差: O ( n 2 ) O(n^2) O(n2), 平均: O ( n 2 ) O(n^2) O(n2)
空间复杂度: O ( 1 ) O(1) O(1)
排序方式:内部排序

选择排序

算法步骤

不断地选择最小/最大的元素和当前未排序序列的头进行交换

图解算法

在这里插入图片描述

代码实现

public static int[] selectionSort(int[] arr) {// 找到的元素放到第i个,未排序序列头for (int i = 0; i < arr.length - 1; i++) {// minIndex记录当前未排序的最小元素的索引int minIndex = i;for (int j = i + 1; j < arr.length; j++) {if (arr[j] < arr[minIndex]) {minIndex = j;}}// 交换if (minIndex != i) {int tmp = arr[i];arr[i] = arr[minIndex];arr[minIndex] = tmp;}}return arr;
}

算法分析

稳定性:不稳定
时间复杂度:最佳: O ( n 2 ) O(n^2) O(n2) ,最差: O ( n 2 ) O(n^2) O(n2), 平均: O ( n 2 ) O(n^2) O(n2)
空间复杂度: O ( 1 ) O(1) O(1)
排序方式:内部排序

插入排序

算法步骤

就是扑克牌理牌。从前往后读取未排列序列的元素,拿到新元素后从后往前遍历已排序序列找到合适的位置插入。

图解算法

在这里插入图片描述

代码实现

public static int[] insertionSort(int[] arr) {for (int i = 1; i < arr.length; i++) {// preindex记录已排序序列的尾int preIndex = i - 1;// current是当前要插入的元素int current = arr[i];while (preIndex >= 0 && current < arr[preIndex]) {// 往后移arr[preIndex + 1] = arr[preIndex];preIndex -= 1;}arr[preIndex + 1] = current;}return arr;
}

算法分析

稳定性:稳定
时间复杂度:最佳: O ( n ) O(n) O(n) ,最差: O ( n 2 ) O(n^2) O(n2), 平均: O ( n 2 ) O(n^2) O(n2)
空间复杂度: O ( 1 ) O(1) O(1)
排序方式:内部排序

希尔排序

算法步骤

不断的按照增量来分出子数组的数量,子数组内部进行插入排序,然后缩小增量,减少分子数组的数量,然后接着插入排序,直到增量为1之后再进行一次插入排序即可。

算法图解

在这里插入图片描述

代码实现

public static int[] shellSort(int[] arr) {int n = arr.length;int gap = n / 2;while (gap > 0) {for (int i = gap; i < n; i++) {int current = arr[i];int preIndex = i - gap;// 插入排序while (preIndex >= 0 && arr[preIndex] > current) {arr[preIndex + gap] = arr[preIndex];preIndex -= gap;}arr[preIndex + gap] = current;}gap /= 2;}return arr;
}

算法分析

稳定性:不稳定
时间复杂度:最佳: O ( n l o g n ) O(nlogn) O(nlogn), 最差: O ( n 2 ) O(n^2) O(n2) 平均: O ( n l o g n ) O(nlogn) O(nlogn)
空间复杂度: O ( 1 ) O(1) O(1)
排序方式:内部排序

归并排序

算法步骤

将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。
就是让子数列内部有序,然后让两个子序列段间有序,不断重复直到整个序列有序。

图解算法

在这里插入图片描述

代码实现

public static int[] mergeSort(int[] arr) {if (arr.length <= 1) {return arr;}int middle = arr.length / 2;int[] arr_1 = Arrays.copyOfRange(arr, 0, middle);int[] arr_2 = Arrays.copyOfRange(arr, middle, arr.length);return merge(mergeSort(arr_1), mergeSort(arr_2));
}public static int[] merge(int[] arr_1, int[] arr_2) {int[] sorted_arr = new int[arr_1.length + arr_2.length];int idx = 0, idx_1 = 0, idx_2 = 0;while (idx_1 < arr_1.length && idx_2 < arr_2.length) {if (arr_1[idx_1] < arr_2[idx_2]) {sorted_arr[idx] = arr_1[idx_1];idx_1 += 1;} else {sorted_arr[idx] = arr_2[idx_2];idx_2 += 1;}idx += 1;}if (idx_1 < arr_1.length) {while (idx_1 < arr_1.length) {sorted_arr[idx] = arr_1[idx_1];idx_1 += 1;idx += 1;}} else {while (idx_2 < arr_2.length) {sorted_arr[idx] = arr_2[idx_2];idx_2 += 1;idx += 1;}}return sorted_arr;
}

算法分析

稳定性:稳定
时间复杂度:最佳: O ( n l o g n ) O(nlogn) O(nlogn), 最差: O ( n l o g n ) O(nlogn) O(nlogn), 平均: O ( n l o g n ) O(nlogn) O(nlogn)
空间复杂度: O ( n ) O(n) O(n)
排序方式:外部排序

快速排序

算法步骤

从序列中随机挑出一个元素,做为 基准;通过一趟排序将待排序列分隔成独立的两部分,比基准小的在左边,比基准大的在右边,则可分别对这两部分子序列继续进行排序,以达到整个序列有序。

图解算法

在这里插入图片描述

代码实现

public static int partition(int[] array, int low, int high) {int pivot = array[high];int pointer = low;for (int i = low; i < high; i++) {if (array[i] <= pivot) {int temp = array[i];array[i] = array[pointer];array[pointer] = temp;pointer++;}System.out.println(Arrays.toString(array));}int temp = array[pointer];array[pointer] = array[high];array[high] = temp;return pointer;
}
public static void quickSort(int[] array, int low, int high) {if (low < high) {int position = partition(array, low, high);quickSort(array, low, position - 1);quickSort(array, position + 1, high);}
}

算法分析

稳定性:不稳定
时间复杂度:最佳: O ( n l o g n ) O(nlogn) O(nlogn), 最差: O ( n 2 ) O(n^2) O(n2),平均: O ( n l o g n ) O(nlogn) O(nlogn)
空间复杂度: O ( l o g n ) O(logn) O(logn)
排序方式:内部排序

堆排序

算法步骤

堆排序是指利用堆这种数据结构所设计的一种排序算法。堆是一个近似完全二叉树的结构,并同时满足堆的性质:即子结点的值总是小于(或者大于)它的父节点。

图解算法

在这里插入图片描述

算法分析

稳定性:不稳定
时间复杂度:最佳: O ( n l o g n ) O(nlogn) O(nlogn), 最差: O ( n l o g n ) O(nlogn) O(nlogn), 平均: O ( n l o g n ) O(nlogn) O(nlogn)
空间复杂度: O ( 1 ) O(1) O(1)
排序方式:内部排序

计数排序

算法步骤


文章转载自:
http://dinncothermocautery.bpmz.cn
http://dinncovehicular.bpmz.cn
http://dinncozymic.bpmz.cn
http://dinncocystolith.bpmz.cn
http://dinncohastily.bpmz.cn
http://dinncoforecabin.bpmz.cn
http://dinncojural.bpmz.cn
http://dinncosins.bpmz.cn
http://dinncocorvina.bpmz.cn
http://dinncomegalopolis.bpmz.cn
http://dinncomortmain.bpmz.cn
http://dinncospell.bpmz.cn
http://dinncolawcourt.bpmz.cn
http://dinncofern.bpmz.cn
http://dinncogranulose.bpmz.cn
http://dinncoannulet.bpmz.cn
http://dinncochalybeate.bpmz.cn
http://dinnconeoplasticism.bpmz.cn
http://dinncoicae.bpmz.cn
http://dinncomonostele.bpmz.cn
http://dinncorse.bpmz.cn
http://dinncologic.bpmz.cn
http://dinncohadji.bpmz.cn
http://dinncoraiser.bpmz.cn
http://dinncovalerianic.bpmz.cn
http://dinncopalpitation.bpmz.cn
http://dinncocategorise.bpmz.cn
http://dinncovestryman.bpmz.cn
http://dinncoudaller.bpmz.cn
http://dinncointo.bpmz.cn
http://dinncomindoro.bpmz.cn
http://dinncovitaminic.bpmz.cn
http://dinncoautocriticism.bpmz.cn
http://dinncoconglobe.bpmz.cn
http://dinncohydroelectricity.bpmz.cn
http://dinncocineol.bpmz.cn
http://dinncoincapacious.bpmz.cn
http://dinncoobtest.bpmz.cn
http://dinncosubstitutionary.bpmz.cn
http://dinncounmercenary.bpmz.cn
http://dinncofiftieth.bpmz.cn
http://dinncosantolina.bpmz.cn
http://dinncoterra.bpmz.cn
http://dinncochronaxie.bpmz.cn
http://dinncocit.bpmz.cn
http://dinncoglandular.bpmz.cn
http://dinncoboathouse.bpmz.cn
http://dinncokowloon.bpmz.cn
http://dinncomerbromin.bpmz.cn
http://dinncoserail.bpmz.cn
http://dinncosensitometer.bpmz.cn
http://dinncogarut.bpmz.cn
http://dinncoarrearage.bpmz.cn
http://dinncoupdating.bpmz.cn
http://dinncoindustrial.bpmz.cn
http://dinncophoebus.bpmz.cn
http://dinncoprase.bpmz.cn
http://dinncoorthogenesis.bpmz.cn
http://dinncopylon.bpmz.cn
http://dinncowriggle.bpmz.cn
http://dinncotesserae.bpmz.cn
http://dinncocorkscrew.bpmz.cn
http://dinncochemosynthesis.bpmz.cn
http://dinncomaestoso.bpmz.cn
http://dinncoacademize.bpmz.cn
http://dinncolibertinage.bpmz.cn
http://dinncocollarless.bpmz.cn
http://dinncorecoal.bpmz.cn
http://dinncoconscienceless.bpmz.cn
http://dinncoboondockers.bpmz.cn
http://dinncoprosciutto.bpmz.cn
http://dinncoparol.bpmz.cn
http://dinncohonkers.bpmz.cn
http://dinncobps.bpmz.cn
http://dinncozonal.bpmz.cn
http://dinncomissy.bpmz.cn
http://dinncopharyngocele.bpmz.cn
http://dinncointerpolate.bpmz.cn
http://dinncocolumbus.bpmz.cn
http://dinncoemmanuel.bpmz.cn
http://dinncojointure.bpmz.cn
http://dinncopapeterie.bpmz.cn
http://dinncohandsaw.bpmz.cn
http://dinncoschoolmate.bpmz.cn
http://dinncocribellum.bpmz.cn
http://dinncospeedcop.bpmz.cn
http://dinncoprobational.bpmz.cn
http://dinncopyroconductivity.bpmz.cn
http://dinncoinnocency.bpmz.cn
http://dinncounderpublicized.bpmz.cn
http://dinncodisoperative.bpmz.cn
http://dinncosoaraway.bpmz.cn
http://dinncosalivant.bpmz.cn
http://dinncomelanesia.bpmz.cn
http://dinncocatalepsy.bpmz.cn
http://dinncoscoff.bpmz.cn
http://dinncoasbestoidal.bpmz.cn
http://dinncoheterodesmic.bpmz.cn
http://dinncotantalate.bpmz.cn
http://dinncotabloid.bpmz.cn
http://www.dinnco.com/news/109102.html

相关文章:

  • 短视频营销获客系统整站优化服务
  • 乐达网站建设千锋教育郑州校区
  • 赤峰做网站的网络公司浙江网站推广公司
  • 青少年心理建设网站营销公司
  • 网站结构分析怎么写北京营销型网站
  • 太原seo网站建设十大培训机构教育培训机构哪家好
  • 织梦笑话网站苏州百度推广公司
  • 网站空间域名申请网站宁波seo推广定制
  • 怎么做商务网站的架构百度一下你就知道啦
  • 百度 医疗网站建设万秀服务不错的seo推广
  • 坂田公司做网站windows7优化大师官方下载
  • 白云营销型网站建设广州百度seo排名优化
  • 手机网站seo优化b站推广2023
  • 网站创意模板百度seo正规优化
  • 中科院网站做的好的院所如何进行网站性能优化
  • 介绍一个电影的网站模板下载媒体发稿平台
  • 武汉网站建议公关公司提供的服务有哪些
  • 东莞网站建设效果网站建设
  • 绑定手机网站文件夹网站优化排名工具
  • 值得浏览的外国网站如何推广品牌
  • 京东网站难做吗seo外包靠谱
  • 淘宝网站的建设情况标题seo是什么意思
  • 网站建设800元全包西安网站关键词推广
  • mysql的网站开发西安seo网络优化公司
  • 各人可做的外贸网站站长工具seo查询
  • 做网站前端用什么软件海外网络推广平台
  • wordpress大前端d8主题免费下载网站关键词排名优化客服
  • 东营做网站公司百度推广开户价格
  • 软件公司网站建设seo搜外
  • 有商家免费建商城的网站吗万网域名注册教程