私はすぐにそれを尋ねようとします:
私は関数としてアルゴリズムを持っています。それを呼び出しましょうf
:
void f(int[1..N]) {
// algorithm goes here
}
これで、入力real runtime
用の がありN
ます。
time()
関数が現在のシステムの時間をミリ秒単位で返すと仮定してください。
int[1...N] n;
unsigned long start = time(), end;
f(N);
end = time();
printf("Real runtime: %ul", end - start);
つまり、f
引数が何ミリ秒かかるかを知っていますN
。
この情報によって、f(N)
実行時の複雑さをどのように計算できf = O(N)
ますか?