我是正常蛇

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年9月2日

摘要: How it worksDivide: Partition the array into two subarrays around a pivot x such that elements in lower subarray ≤ x ≤ elements in upper subarray.Conquer: Recursively sort the two subarrays.Combine: Trivial.How to divide(Assume the array is start at p and end at q)1. First gives two pointer i j , i 阅读全文
posted @ 2012-09-02 20:55 我是正常蛇 阅读(217) 评论(0) 推荐(0) 编辑

摘要: Steps:Divide the problem (instance) into subproblems.Conquer the subproblems by solving them recursively.Combine subproblem solutions.A typical algorithm solved by D&V is merge sort. Frist we partitions the array into two sorted array recursivly, that is the Dvide part.Then we combine the two so 阅读全文
posted @ 2012-09-02 20:49 我是正常蛇 阅读(216) 评论(0) 推荐(0) 编辑

摘要: There are 3 methods to work out a Recurrence.Substitution method.Steps:Guess the result.Prove it by induction.Ex: T(n) = 4T(n/2) + n[Assume that T(1) = Θ(1)]Guess O(n3) . (Prove O and Ω separately.)Assume that T(k) ≤ ck3 for k < n .Prove T(n) ≤ cn3 by induction.T (n) = 4T (n / 2) + n ≤ 4c ( n / 2 阅读全文
posted @ 2012-09-02 19:21 我是正常蛇 阅读(421) 评论(0) 推荐(0) 编辑