asymptoticOΩΘ O(log(n)) hidden constant

使N1 log2 N+1 

コストモデル

編集

2121000

2使[1][2][3][4][5]









使

[6]

実行時間解析

編集

 n1

実測の問題点

編集



 nAB2
n(リストの大きさ) コンピュータAの実行時間
(ナノ秒単位)
コンピュータBの実行時間
(ナノ秒単位)
15 7 100,000
65 32 150,000
250 125 200,000
1,000 500 250,000

この測定結果を見ると、コンピュータAで実行したアルゴリズムの方がコンピュータBのそれよりも遥かに高速だと結論しそうになる。しかし、入力リストの大きさを十分大きくすると、その結論は全くの間違いだったことが判明する。

n(リストの大きさ) コンピュータAの実行時間
(ナノ秒単位)
コンピュータBの実行時間
(ナノ秒単位)
15 7 100,000
65 32 150,000
250 125 200,000
1,000 500 250,000
... ... ...
1,000,000 500,000 500,000
4,000,000 2,000,000 550,000
16,000,000 8,000,000 600,000
... ... ...
63,072 × 1012 31,536 × 1012 ナノ秒、
または1年
1,375,000 ナノ秒,
または 1.375 ミリ秒

A2244B225,000ABB

成長のオーダー

編集

 n f(n)  n n0  c × f(n) cO O(n2) 

O使使 O(n2)  O(n log n) 

経験的な成長のオーダー

編集

  k na 2       a[7]      aa 2
n(リストの大きさ) コンピュータAの実行時間
(ナノ秒単位)
ローカルな成長オーダー
(n^_)
コンピュータBの実行時間
(ナノ秒単位)
ローカルな成長オーダー
(n^_)
15 7 100,000
65 32 1.04 150,000 0.28
250 125 1.01 200,000 0.21
1,000 500 1.00 250,000 0.16
... ... ...
1,000,000 500,000 1.00 500,000 0.10
4,000,000 2,000,000 1.00 550,000 0.07
16,000,000 8,000,000 1.00 600,000 0.06
... ... ...

AB aB

実行時間複雑性の評価

編集

調
1入力から正の整数nを得る2if n > 10
3        print "This might take a while..."
4    for i = 1 to n
5        for j = 1 to i
6            print i * j
7    print "Done!"

使[8]1T12T2 

1271311237

 

4564 ( n + 1 ) n n + 1 T4( n + 1 ) i1nj1116T65 2T5j1226 2T65 3T5 



 

[9]

 



 


 



 



 



 

 n2f(n) = O(n2) 


  

 

   n  0


k [T1..T7] 

 
  (for n  1)  


     


[T1..T7] [10]

  (for n  1)  

他のリソースの成長率解析

編集

使使
while (ファイルはオープン中)
    let n = ファイルのサイズ
    for ファイルサイズが100,000キロバイト増加するごとに
        確保するメモリ量を倍にする

 n使 O(2n) [11]

意義

編集

使



Unix

脚注

編集


(一)^ Alfred V. Aho; John E. Hopcroft; Jeffrey D. Ullman (1974). The design and analysis of computer algorithms. Addison-Wesley Pub. Co. , section 1.3

(二)^ Juraj Hromkovič (2004). Theoretical computer science: introduction to Automata, computability, complexity, algorithmics, randomization, communication, and cryptography. Springer. pp. 177178. ISBN 978-3-540-14015-3. https://books.google.co.jp/books?id=KpNet-n262QC&pg=PA177&redir_esc=y&hl=ja 

(三)^ Giorgio Ausiello (1999). Complexity and approximation: combinatorial optimization problems and their approximability properties. Springer. pp. 38. ISBN 978-3-540-65431-5. https://books.google.co.jp/books?id=Yxxw90d9AuMC&pg=PA3&redir_esc=y&hl=ja 

(四)^ Wegener, Ingo (2005), Complexity theory: exploring the limits of efficient algorithms, Berlin, New York: Springer-Verlag, p. 20, ISBN 978-3-540-21045-0, https://books.google.co.jp/books?id=u7DZSDSUYlQC&pg=PA20&redir_esc=y&hl=ja 

(五)^ Robert Endre Tarjan (1983). Data structures and network algorithms. SIAM. pp. 37. ISBN 978-0-89871-187-5. https://books.google.co.jp/books?id=JiC7mIqg-X4C&pg=PA3&redir_esc=y&hl=ja 

(六)^ Examples of the price of abstraction?, cstheory.stackexchange.com

(七)^ How To Avoid O-Abuse and Bribes, at the blogGödels Lost Letter and P=NPby R. J. Lipton, professor of Computer Science at Georgia Tech, recounting idea by Robert Sedgewick

(八)^ 

(九)^   

(十)^ 

(11)^ 

参考文献

編集

関連項目

編集