2 ms·
Suppose you had three functions. F1(n) = 1 second * n + 1 day = O(n) F2(n) = 1 millisecond * n + 1 month = O(n) F3(n) = 1 nanosecond * n ^ 2 + 1 millisec
by Retric 13y ago
Suppose you had three functions.
F1(n) = 1 second * n + 1 day = O(n)
F2(n) = 1 millisecond * n + 1 month = O(n)
F3(n) = 1 nanosecond * n ^ 2 + 1 millisecond = O(n^2)
For really big numbers both F1 and F2 are faster but at n = 100 F3 has a huge lead and for say n = 1 billion F3 beats F1 but not F2.