Introduction to Algorithms Second Edition by:算法导论第二版的文档.pptVIP

  • 11
  • 0
  • 约9.73千字
  • 约 34页
  • 2018-02-27 发布于湖北
  • 举报

Introduction to Algorithms Second Edition by:算法导论第二版的文档.ppt

Introduction to Algorithms Second Edition by:算法导论第二版的文档

* * * * * * * * * * * * * * MERGE-SORT(A, 1, n) * The two largest elements in two arrays are sentinels Execute r-p+1 times * * Merging: MERGE(A, p, q, r) Input: Array A and indices p, q, r such that p ? q ?r Subarray A[p .. q] is sorted and subarray A[q+1 .. r] is sorted. By the restrictions on p, q, r, neither subarray is empty. Output: The two subarrays are merge into a single sorted subarray in A[p .. r]. T(n) = ?(n), where n=r-p+1 = the # of elements being merged. What is n ? The size of the original problem = the size of a subproblem. Use this technique when we analyze recursive

文档评论(0)

1亿VIP精品文档

相关文档