
算法学习
文章平均质量分 78
quanspacer
这个作者很懒,什么都没留下…
展开
-
POJ1001 Exponenentiation
POJ1001Problems involving the computation of exact values of very large magnitude and precision are common.For example, the computation of the national debt is a taxing experience for many compute原创 2013-01-13 17:32:05 · 525 阅读 · 0 评论 -
implement the maximum subarray using dynamic programming
the time complexity is O(n)./* modified by quanspace 2013-01-30 * 实现最大子段和问题的线性级的算法 a linear time algorithm from Jay Kadane * 最大子段和 maxsum 要么是空,取特定值0, 要么是 a[i]..a[j] 0<= i<= j<=n . * a simple原创 2013-02-02 18:38:45 · 335 阅读 · 0 评论 -
implement The Maximum Subarray using divide and conquer
分3种情况,1.最大子段和可能整段在数组的左边,2.可能在数组的右边 3.也可能穿过中点先分析过中点的情况。可以先从中间元素开始向两边求出左右各自的最大子段和,然后合并,《算法导论》给出的 pseudocode 如下:FIND_MAX_CROSSING_SUBARRAY(A, low, mid, high)left_sum = -∞sum = 0for i = mid downto原创 2013-01-22 16:43:05 · 565 阅读 · 0 评论 -
Analysis and implement some simple sorting algorithm.(2)——heapsort
//modified by quanspace 2013-02-19 20:16//the time complexity is O(nlgn).# include # include using namespace std;class heapsort{ public: void print_heap(int a[], int a_size); void max_原创 2013-02-19 21:02:01 · 374 阅读 · 0 评论 -
Analysis and implement some simple sorting algorithm.(1)
simple sorting algorithm Input:A sequence of n numbers Output: A reordering permutation of the input sequence.( ex. in ascending order)1.Insertion sort 插入算法 就像我们玩扑克在摸牌一样,每次从牌堆里抽出一张牌都将其插入手牌原创 2013-01-18 18:08:30 · 373 阅读 · 0 评论