摘要: 上一篇中写了选择排序和插入排序,都是O(N^2)级别的,这篇将要实现的归并排序和快速排序都是O(Nlog(N))级别的。 归并排序 思路;首先将要排序的数组分成两部分,left_part,right_part,之后将排好序的left_right和right_part归并起来,同原始数组一样,被分成的 阅读全文
posted @ 2018-07-14 22:12 Holly_U 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 选择排序 选择排序的思想非常简单,很多书或技术Blog都讲的很好,这里不赘述了,直接给出代码 如果考虑通用性,可以使用模板函数 插入排序 插入排序的思想非常简单,无论是经典教材《算法导论》还是不少技术文章都以扑克牌为例,手里的牌是有序的,每拿到一张新牌会为它在排好序的牌中找出合适的位置插入。 代码如 阅读全文
posted @ 2018-07-14 18:05 Holly_U 阅读(1535) 评论(0) 推荐(0) 编辑
摘要: 被搁置的计划 It was the best of times,it was the worst of times,it was the age of wisidom,it was the age of foolishness,it was the epoch of belief,it was th 阅读全文
posted @ 2018-07-14 09:25 Holly_U 阅读(197) 评论(0) 推荐(0) 编辑