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.
このコードの Big-O 表記法は何ですか?
for(int i=0; i<10; ++i) for(int a=0; a<n; ++a){ cout << "*"; cout << endl; }
これはO(n): 外側のループの 10 は単なる定数です。
O(n)
これO(10*n)はO(n)、10 が定数係数だからです。
O(10*n)
大きな問題は、O(10*n) -> O(n) です。