0
我幾天前就開始研究數據結構和算法,並且仍然試圖理解這些概念。我正在學習Big-O符號。我明白O(1) - 時間複雜性是什麼,並且有問題。以下代碼片段的大O表示法
void Method1(int n) {
int a = 10;
int b = 20;
int x = a + n;
int y = b * n;
Console.Writeline("{0}{1}", x, y);
}
上面代碼的複雜度是O(1)對於非常大的值n。我們使用N的值而不是處理N.下面的方法是否仍然具有相同的複雜度,其中n和m是非常大的數字作爲輸入。
void Method1(int n, int m) {
int a = 10;
int b = 20;
int x = a + n;
int y = b * m;
Console.Writeline("{0}{1}", x, y);
}
[如何找到算法的時間複雜度](https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm) – hatchet