算法设计与分析
文章平均质量分 73
Dorr朵儿
小草一样的人生,但是却有一颗想成为大树的心。
展开
-
Divide and Conquer&Count Inversions归并排序求逆序数
Divide and ConquerThe attached le Q8.txt contains 100,000 integers between 1 and 100,000 (each row has a single integer), the order of these integers is random and no integer is repeated.刚写程序是用的vi原创 2016-09-29 16:48:06 · 684 阅读 · 0 评论 -
快排求逆序数&快排与归并时间复杂度比较
本文参考其他用快排求逆序数的方法。在用快排求解逆序数前,我先考虑了这个问题,1:归并和快排的时间复杂度都是nlog(n),为什么不用归并?我认为应该是由于快排在每次合并时都有用到临时数组,然后每次还需要把临时数组重新copy到原数组中 ,增加了时间复杂度;快排虽然也存在最坏的情况,即n^2,但是由于其随机性,所以期望的时间复杂度仍然是nlog(n),因此如果能用快排求逆序数的话,也是不错的原创 2016-10-02 19:14:21 · 2158 阅读 · 0 评论 -
分治法求最近点对
Dvide and ConquerImplement the algorithm for the closest pair problem in your favourite language.INPUT: n points in a plane.OUTPUT: The pair with the least Euclidean distance.算法的思想:首先对原创 2016-10-05 14:03:43 · 4322 阅读 · 0 评论 -
Karatsuba algorithm乘法问题
Divide and ConquerImplement the Karatsuba algorithm for Multiplication problem in your favourite language,and compare the performance with quadratic grade-school method.只需要3次乘法,6次加法,原创 2016-10-05 17:15:51 · 3322 阅读 · 0 评论