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.
プログラムの次のセグメントの時間計算量は O(2^n) でしょうか? よくわかりません
n=1; for j=1 to n do output(j); n=2*n; end {for}
いいえ、これはO(n)です。
nを2^n乗しただけです。
これは、最終的な回答やループ内の計算に関係なく、ループの反復回数が「n」であるためです。