From Wikipedia, the free encyclopedia
冒泡排序(英文:bubble sort或sinking sort)係一種用嚟將一個數列入面啲數字由細至大排好嘅演算法,做法係喺每一步攞相鄰嘅兩個數比較,將兩個數由細到大排好,再將個過程做若干次,做到成個數列都排好嗮為止。原則上,冒泡排序並唔好用-喺最壞情況下要行成 咁多步先行得完,所以喺現實,冒泡排序多數都淨係俾人用嚟做電腦科學上嘅教育用途[1][2]。
例如如果用冒泡排序同 5, 1, 4, 2, 8
呢個數列排序嘅話:
喺2007年一個問答環節入邊,前Google CEO Eric Schmidt問當時嘅美國總統候選人奧巴馬將一百萬個整數排序最好嘅方法係乜,奧巴馬諗咗一陣答:「冒泡排序應該唔係一個好方法。」(I think the bubble sort would be the wrong way to go.)[3][4]
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.