章演算法分析.pptVIP

  • 2
  • 0
  • 约3.33千字
  • 约 18页
  • 2020-07-21 发布于湖北
  • 举报
第 1 章 演算法分析 目次 1.1 演算法 1.2 Big-O 1.3 動動腦時間 1.4 練習題解答 1.1 演算法 演算法(Algorithms)? 是一解決問題(problems)的有限步驟程序 產生解答中一步一步的程序 程式效率分析方式(performance analysis) 時間複雜度分析(time complexity analysis) 空間複雜度分析(space complexity analysis) 1.1 演算法(con.t) 時間複雜度分析步驟 求出程式中每一敘述的執行次數( ‘{‘ 和 ’}’ 不計算) 再將這些執行次數加總 求出程式之Big-O,即為該程式之時間複雜度 Ex:四個範例 1.1.1 陣列元素相加    執 行 次 數 int sum(int arr[], int n) { int i, total=0; 1 for (i=0; in; i++) n+1 total+=arr[i]; n return total; 1 } 2n+2 1.1.2 矩陣相加 執 行 次 數 void add (int a[][], int b[][], int

文档评论(0)

1亿VIP精品文档

相关文档