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

06 2011 档案

 
算法导论(CLRS, 2nd) 个人答案 Ch2.2
摘要:2.2-1:O(n^3)2.2-2:Selection-Sort(A): for( i=0 ; i<A.size()-1 ; i++){ max = A[i]; index = 0; for(j=i+1; j<A.size(); j++){ if(max < A[j]){ max = A[j]; index = j; } } // then swap the next max and the current element A[j] = A[i]; A[i] = max; }2.2-3:Say we're sorting nelementsWorst Case: nB 阅读全文
posted @ 2011-06-30 18:51 songyy 阅读(340) 评论(0) 推荐(0)
 

公告


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