Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
x = x + 1以下のセグメントでステートメントが実行された回数について、nに関するΘ表記を見つけます。
x = x + 1
i = 1 while (i < n^2) x = x + 1 i = 3i
iの成長率はわかっていますが、の表記O(3^k)方法がわかりません。Θn
i
O(3^k)
Θ
n
与えられた、前からn何回実行できるかを知る必要があります。あなたはすでにステップの後、あなたのタスクが解決していることを知っていますi = 3*ii = 1i >= n^2ki = 3^k
i = 3*i
i = 1
i >= n^2
k
i = 3^k
3^(k-1) < n^2 <= 3^k
、つまりk、の関数として書き込みnます。