• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
厚积薄发
| 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2011年7月1日

算法导论(CLRS, 2nd) 个人答案 Ch2 end of chapter
摘要: 2-1:2-2:a) loop invariant,initial condition, termination condition.b) A[j] is thesmallest element in A[j .. length[A]]. initialization: at the start of the loop, j = length[A].It's the smallest element in A[length[A] ~ length[A]] (because it'sthe only element). maintenance: if j = k is the s 阅读全文
posted @ 2011-07-01 16:18 songyy 阅读(729) 评论(0) 推荐(0)
 
算法导论(CLRS, 2nd) 个人答案 Ch2.3
摘要: 2.3-1:2.3-2:function MERGE-IMPROVED(A,p,q,r){ create array B[0 ... r - p]; int i = p, j = q+1, t =0; while(i<=q && j<=r){ if(A[i] >= A[j]){ B[t++] = A[j++]; } else{ B[t++] = A[i++]; } } if(i>q){ // i pile exhaustedwhile(j<=r) B[t++] = A... 阅读全文
posted @ 2011-07-01 12:07 songyy 阅读(491) 评论(4) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3