【正文】
(2n)、階乘 (n!) Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 Engineering 22 算法的經(jīng)驗(yàn)分析 ?對算法效率做經(jīng)驗(yàn)分析的通用方案 ?了解試驗(yàn)的目的 ?決定用來度量效率的量度 M和度量單位(單位時間內(nèi)的操作次數(shù)) ?決定輸入樣本的特性 ?為實(shí)驗(yàn)準(zhǔn)備算法的程序?qū)崿F(xiàn) ?生成輸入樣本 ?對輸入樣本進(jìn)行計算,并記錄觀察到的實(shí)驗(yàn)數(shù)據(jù) ?分析獲得的實(shí)驗(yàn)數(shù)據(jù) Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 ?時間效率主要用它的輸入規(guī)模的函數(shù)來度量,該函數(shù)計算算法基本操作的執(zhí)行次數(shù)。 Engineering 27 動態(tài)算法可視法 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 4. 建立一個算法基本操作執(zhí)行次數(shù)的求和表達(dá)式。 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 ?基本操作 通常是算法最內(nèi)層循環(huán)中最費(fèi)時的操作。 Time is Important 不是所有能計算的都有價值,不是所有有價值的都能被計算 —— 阿爾伯特 .愛因斯坦 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 ?對于所有的算法,對于規(guī)模更大的輸入都需要運(yùn)行更長的時間。 一個需要指數(shù)級操作次數(shù)的算法只能用來解決規(guī)模非常小的問題 Analysis and Design of Computer Algorithms Yunnan University School of Information Science amp。 Engineering 9 符號 O ? 定義 1 對于足夠大的 n, t(n)的上界由 g(n)的常數(shù)倍來確定,即: ? 記為 t(n) ∈ O(g(n)) t(n) ≤ cg(n), c為常數(shù)