访问次数
我的另一个总结性博客: todototry 大米粒
摘要: Θ(n^2)1, Bubble sortRuby代码defbubble_sort(a)(a.size-2).downto(0)do|i|(0..i).eachdo|j|a[j],a[j+1]=a[j+1],a[j]ifa[j]>a[j+1]endendreturnaend2, Selection sortRuby代码defselection_sort(a)b=[]a.size.timesdo|i|min=a.minb<<mina.delete_at(a.index(min))endreturnbend3, Insertion sortRuby代码definsertion_so 阅读全文
posted @ 2011-10-15 19:58 fandyst 阅读(333) 评论(0) 推荐(0) 编辑