骨密度挂什么科| 炖鸡汤放什么调料| 黄瓜和什么不能一起吃| 手足口病有什么症状| 膀胱充盈欠佳什么意思| 苏打水喝了有什么好处| 亚麻色是什么颜色| 鸡肉配什么菜好吃| rrl是什么牌子| 卵巢早衰是什么引起的| 晚上喝什么茶好| 东方是什么意思| 肚子疼发烧是什么病症| 蒙脱石散是什么| 血脂高是什么意思| 长期便秘是什么原因| 为什么游戏| 918是什么日子| 卵泡是什么东西| 孩子高低肩有什么好办法纠正| 套马的汉子你威武雄壮是什么歌| 芙蓉粉是什么颜色| 显妣是什么意思| 艾灸灸出水泡是什么情况| qrs波代表什么| 嘴巴长疱疹用什么药| 娘子啊哈是什么歌| 蛋白烫发是什么意思| 化验肝功挂什么科| 肺间质纤维化是什么病| 15朵玫瑰花代表什么意思| 打乙肝疫苗需要注意什么| 人的胆量由什么决定| 车前草的作用是什么| 航班号是什么| 中校相当于政府什么官| 早餐吃什么最营养| hold on什么意思| 前胸后背长痘痘用什么药| 臣服什么意思| 身家是什么意思| 乳酸菌是什么菌| 花生属于什么类| 手指肿胀什么原因| 总打喷嚏是什么原因| 的字五行属什么| 吃一个海参相当于吃了什么| 什么是1型和2型糖尿病| 经常拉肚子是什么原因| 头孢治疗什么| 托孤是什么意思| 2001属什么生肖| 接龙是什么意思| 冰袋里面装的是什么| 梅毒查血查什么项目| 怕冷是什么原因| 口腔溃疡什么症状| 卵是什么意思| 铁是补什么的| 什么人不宜吃石斛| 立春吃什么| 小孩抽动症是什么引起的| 赛马不相马什么意思| 肛周水泡是什么病| 吃什么能升血小板| 不什么好什么| 精液是什么味| 腰肌劳损是什么原因引起的| 胃火旺喝什么茶| 什么是创造性思维| 宫腔内稍高回声是什么意思| 梦见买楼房有什么预兆| 月经量多是什么原因引起的| 什么叫换手率| essence是什么意思| 什么是修辞手法| 长期口臭吃什么药| 死海为什么叫死海| 心阴不足吃什么中成药| 终其一生下一句是什么| 针眼长什么样子图片| 什么是补铁的食物| 圆圆的月亮像什么| 早上起床有眼屎是什么原因| 心律不齐什么症状| 60岁是什么之年| 癫痫病是什么症状| 鱼眼睛吃了有什么好处| 西柚是什么季节的水果| 尿酸高吃什么能降| 吃什么睡眠好的最快最有效| 吃什么东西可以降压| 左眼跳什么预兆| 稷字五行属什么| 杨桃是什么季节的水果| 弄虚作假是什么生肖| 青睐什么意思| 霸道是什么意思| 什么是肾虚| 高血脂不能吃什么| 风团是什么原因引起的| 夜深人静是什么意思| 开天辟地是什么生肖| 什么叫逻辑思维| 吃汉堡为什么要配可乐| nhl医学上是什么意思| 伤口结痂为什么会痒| 中国的国球是什么| 晚上8点半是什么时辰| 乳酸菌和益生菌有什么区别| 眼睛红痒用什么眼药水| 什么是ppi| 为什么医院不推荐钡餐检查| 00属什么生肖| 爱马仕是什么牌子| 遗传是什么意思| 注意力不集中是什么原因| 足字旁的字有什么| 为什么家里有蚂蚁| 乳腺发炎有什么症状| 甲状腺功能亢进症是什么病| 稀料是什么| alpha什么意思| 衔接班是什么意思| 婴儿不睡觉是什么原因| 什么是211大学| 答辩是什么| s和m是什么意思| 芒果有什么营养| 大步向前走永远不回头是什么歌| 舌苔黄腻吃什么中成药| 一什么田野| 白色t恤配什么裤子| 知柏地黄丸治疗什么病| 88年的属什么生肖| 妈妈生日送什么礼物好| 六月是什么生肖| 怀二胎初期有什么症状| xxoo什么意思| 诺如病毒吃什么药好得快一点| 什么中药可以减肥| 六味地黄丸是治什么病| 广义货币m2是什么意思| 1977年是什么年| 糖尿病喝什么茶| 什么水果补充维生素c| 道貌岸然是什么生肖| 醋酸菌是什么菌| 大脑缺氧有什么症状| 大连有什么特产| 最新奥特曼叫什么| 做月子要注意什么| 尿肌酐是什么意思| 什么动物没尾巴| 什么是夫妻共同财产| 公鸡蛋是什么| 老舍原名什么| 甲状腺结节有什么症状表现| 西湖醋鱼是什么鱼| 南瓜吃了有什么好处| 意味深长的意思是什么| 505是什么意思| 什么食物含蛋白高| 癣用什么药| 声音嘶哑吃什么药好| 精索是什么| 为什么会得卵巢肿瘤| 可见一什么| 智齿什么样子| 胃热吃什么药| 手容易出汗是什么原因| 猪肝有什么功效与作用| 向日葵什么时候成熟| 眼睛干痒用什么眼药水| 衣带渐宽终不悔是什么意思| 楞严神咒是什么意思| 套话是什么意思| 吃你鲍鱼是什么意思| 寡淡是什么意思| 小产后可以吃什么水果| 抄送和密送是什么意思| 频繁流鼻血是什么原因| 手机服务密码是什么| hvp阳性是什么病| alex是什么意思| 子宫癌是什么症状| 卵泡期什么意思| 果冻是什么意思| 白天不懂夜的黑是什么意思| 美满霉素又叫什么名字| gj是什么意思| 00后属什么生肖| 肾病可以吃什么水果| 胆囊切除对身体有什么影响| food什么意思| 为什么总是莫名其妙的想哭| 吃了阿莫西林不能吃什么| 黑京念什么| 喉咙干燥吃什么药| 胎儿没有胎心是什么原因| 幽门螺旋杆菌感染吃什么药| 清水文是什么意思| 寒食节是什么时候| ray是什么意思| 积液是什么原因造成的怎么治疗| wifi用户名是什么| 什么是风湿病| lo什么意思| 医学mr是什么意思| 天麻什么味道| 尿是绿色的是什么原因| 肾病什么东西不能吃| 梦见打死黄鼠狼是什么意思| 想飞上天和太阳肩并肩是什么歌| 嘴唇周围长痘痘是什么原因| 尿隐血弱阳性什么意思| 为什么这样对我| 葫芦代表什么生肖| 这句话是什么意思| 小虾吃什么| 白发是什么原因引起的| 为什么会有荨麻疹| 梦到蛇什么意思| 市长什么级别| 虚岁28岁属什么生肖| 轻度抑郁有什么症状| 糖尿病患者可以吃什么水果| 更年期吃什么药调理| 衬衫什么面料好| 沙僧是什么动物| adivon是什么牌子| 什么是易经| 县长什么级别干部| 补钾吃什么药| 头晕可以吃什么药| 中国地图像什么| 孑孓什么意思| 为什么会得人工荨麻疹| 黄金分割点是什么| 面粉是什么粉| 食物中毒吃什么药解毒| 倍感欣慰是什么意思| 白麝香是什么味道| 什么罗之恋| 央企和国企有什么区别| 甲醛会导致什么病| 流产有什么症状| 桔色搭配什么颜色好看| 古惑仔为什么不拍了| 自言自语的近义词是什么| 三百多分能上什么大学| 逆转是什么意思| 挛缩是什么意思| 孕妇脚肿是什么原因| 2点是什么时辰| 女人梦见下雪是什么征兆| 送长辈什么礼物合适| 糖类抗原153偏高是什么原因| helen是什么意思| 鬼代表什么数字| 股骨长是指什么| 肝脏彩超能检查出什么| 什么叫骨折| 阴囊湿疹是什么原因造成的| 百度Jump to content

天秤座和什么座最配对

From Wikipedia, the free encyclopedia
Comb sort
Visualisation of comb sort
Comb sort with shrink factor k=1.24733
ClassSorting algorithm
Data structureArray
Worst-case performance[1]
Best-case performance
Average performance, where p is the number of increments[1]
Worst-case space complexity
百度 他也承认正是因为酗酒,让他的NBA生涯早早结束,并透露尽管从小就贩毒,但他并没有过度迷恋毒品。

Comb sort is a relatively simple sorting algorithm originally designed by W?odzimierz Dobosiewicz and Artur Borowy in 1980,[1][2] later rediscovered (and given the name "Combsort") by Stephen Lacey and Richard Box in 1991.[3] Comb sort improves on bubble sort in the same way that Shellsort improves on insertion sort, in that they both allow elements that start far away from their intended position to move more than one space per swap.

nist.gov's "diminishing increment sort" definition mentions the term 'comb sort' as visualizing iterative passes of the data, "where the teeth of a comb touch;" the former term is linked to Don Knuth.[4]

Algorithm

[edit]

The basic idea is to eliminate turtles, or small values near the end of the list, since in a bubble sort these slow the sorting down tremendously. Rabbits, large values around the beginning of the list, do not pose a problem in bubble sort.

In bubble sort, when any two elements are compared, they always have a gap (distance from each other) of 1.[5] The basic idea of comb sort is that the gap can be much larger than 1. The inner loop of bubble sort, which does the actual swap, is modified such that the gap between swapped elements goes down (for each iteration of outer loop) in steps of a "shrink factor" k: [?n/k?, ?n/k2?, ?n/k3?, ..., 1].

The gap starts out as the length of the list n being sorted divided by the shrink factor k (generally 1.3; see below) and one pass of the aforementioned modified bubble sort is applied with that gap. Then the gap is divided by the shrink factor again, the list is sorted with this new gap, and the process repeats until the gap is 1. At this point, comb sort continues using a gap of 1 until the list is fully sorted. The final stage of the sort is thus equivalent to a bubble sort, but by this time most turtles have been dealt with, so a bubble sort will be efficient.

The shrink factor has a great effect on the efficiency of comb sort. Dobosiewicz suggested k = 4/3 = 1.333…, while Lacey and Box suggest 1.3 as an ideal shrink factor after empirical testing on over 200,000 random lists of length approximately 1000. A value too small slows the algorithm down by making unnecessarily many comparisons, whereas a value too large fails to effectively deal with turtles, making it require many passes with a gap of 1.

The pattern of repeated sorting passes with decreasing gaps is similar to Shellsort, but in Shellsort the array is sorted completely each pass before going on to the next-smallest gap. Comb sort's passes do not completely sort the elements. This is the reason that Shellsort gap sequences have a larger optimal shrink factor of about 2.25.

One additional refinement suggested by Lacey and Box is the "rule of 11": always use a gap size of 11, rounding up gap sizes of 9 or 10 (reached by dividing gaps of 12, 13 or 14 by 1.3) to 11. This eliminates turtles surviving until the final gap-1 pass.

Pseudocode

[edit]
function combsort(array input) is

    gap := input.size // Initialize gap size
    shrink := 1.3 // Set the gap shrink factor
    sorted := false

    loop while sorted = false
        // Update the gap value for a next comb
        gap := floor(gap / shrink)
        if gap ≤ 1 then
            gap := 1
            sorted := true // If there are no swaps this pass, we are done
        else if gap = 9 or gap = 10 then
            gap := 11      // The "rule of 11"
        end if

        // A single "comb" over the input list
        i := 0
        loop while i + gap < input.size // See Shell sort for a similar idea
            if input[i] > input[i+gap] then
                swap(input[i], input[i+gap])
                sorted := false
                // If this assignment never happens within the loop,
                // then there have been no swaps and the list is sorted.
             end if
    
             i := i + 1
         end loop
     end loop
end function

See also

[edit]
  • Bubble sort, a generally slower algorithm, is the basis of comb sort.
  • Cocktail sort, or bidirectional bubble sort, is a variation of bubble sort that also addresses the problem of turtles, albeit less effectively.

References

[edit]
  1. ^ a b c Brejová, Bronislava (15 September 2001). "Analyzing variants of Shellsort". Information Processing Letters. 79 (5): 223–227. doi:10.1016/S0020-0190(00)00223-4.
  2. ^ Dobosiewicz, Wlodzimierz (29 August 1980). "An efficient variation of bubble sort". Information Processing Letters. 11 (1): 5–6. doi:10.1016/0020-0190(80)90022-8.
  3. ^ Lacey, Stephen; Box, Richard (April 1991). "A Fast, Easy Sort: A novel enhancement makes a bubble sort into one of the fastest sorting routines". Hands On. Byte Magazine. Vol. 16, no. 4. pp. 315–318, 320. Archived from the original on 2025-08-07. Entire magazine available at archive.org.
  4. ^ "diminishing increment sort". Retrieved March 9, 2021.
  5. ^ "comb sort". National Institute of Standards and Technology (nist.gov). Retrieved March 9, 2021.
兔子的眼睛为什么是红色的 什么的雪花 蛇的贵人是什么生肖 肝结节挂什么科 心功能三级是什么意思
抗战纪念日为什么是9月3日 mds是什么 梦见桥塌了有什么预兆 感谢是什么意思 李莫愁的徒弟叫什么
二次元谷子是什么意思 房性早搏吃什么药最好 维他命是什么 为什么说婴儿摔床没事 吃什么可以补黄体酮
好聚好散是什么意思 有人的地方就有江湖什么意思 肌肉痉挛用什么药能治好 61岁属什么 84消毒液不能和什么一起用
食糜是什么意思yanzhenzixun.com vod是什么意思hcv8jop8ns9r.cn 爬虫是什么hcv8jop0ns9r.cn 圣字五行属什么onlinewuye.com 用什么可以全身美白hcv9jop5ns5r.cn
说梦话是什么原因引起的hcv9jop2ns3r.cn 印度人属于什么人种luyiluode.com 武则天姓什么aiwuzhiyu.com 什么是肌张力dajiketang.com 粉黛是什么意思hcv8jop5ns6r.cn
世界上最深的湖是什么huizhijixie.com 什么东西最隔音hcv8jop9ns6r.cn 胃出血吃什么食物好养胃hcv8jop5ns6r.cn 多囊卵巢是什么hcv7jop4ns7r.cn 经常嗓子哑是什么原因hcv7jop4ns8r.cn
象牙有什么作用与功效hcv8jop2ns1r.cn 木冉读什么hcv7jop9ns5r.cn 女性口臭都是什么原因hcv8jop5ns0r.cn 红斑狼疮复发的症状是什么hcv8jop0ns7r.cn 平常平时叫什么日hcv9jop1ns4r.cn
百度