氣泡排序 單例

2021-09-28 17:56:01 字數 786 閱讀 6871

第一種:始終比較第一層for迴圈的第i個元素

/**

* 氣泡排序,公升序排序

* 始終將第i個數與第j個數相比較

** @author mekhi

* @date 2019/10/17 16:23

*/public

static

void

bubblesort()

;//外層for迴圈控制迴圈次數

for(

int i =

0; i < arr.length; i++)}

}for

(int item : arr)

}

第二種:相鄰元素兩兩比較

/**

* 氣泡排序,公升序排序

* 始終將最大的向上冒泡

* 第一遍for完成後,最後乙個必然是最大的

* 此時,在進行下一次的for迴圈時,jpublic

static

void

bubblesort()

;for

(int i=

0;i1;i++)}

}for

(int item : arr)

}

單例

public

class

singleton

public singleton getsingleton()

}}return singleton;

}}

單鏈表氣泡排序

一.題目 如題.二.package week 4 單鏈表氣泡排序 author dingding date 2017 7 3 12 25 public class sortlink solution,氣泡排序,直接交換兩個值,關鍵在於迴圈條件 private static node sort nod...

單鏈表 氣泡排序

main.c bubblesortlinkedlist headnode created by chenyufeng on 16 3 1.對帶頭結點的單鏈表進行氣泡排序,並列印 include include include typedef int elemtype typedef struct n...

單鏈表氣泡排序

今天做鍊錶排序有個誤區,就是以為交換的時候要連next節點也交換,還要固定head節點,想了很久也沒做出來,但是後來看網上的提示,才知道只要交換節點內的資料就可以了,根本不用交換next節點 include include struct node struct node create list in...