Hello, Citizens of the World,
Topic of the day: Efficiency of Algorithms, Big O
Comparison of the Growth of Functions
When M is arbitrarily large, a functions growth depends on the term with the highest base (the dominant term).
Ignore the coefficient of the greatest term in the function.
There are different notations:
20n + 5 = O(n)
200n + 1 000 000 = O(n)
200n^2 + n - 19 = O(n^2)
300n^2 + 12345n + 23 = O(n^2)
75n^3 + 4n^2 = O(n^3)
s + 3333 log n + 12343 n log n = O(n log n)
2^s + 1050s^2 = O(2^s)
2340(2^n) + 5000 (n^200) = O(2^n)
Notice how the value in the brackets is the "dominant term".
Ordering:
20n + 5 = O(n) -> 1
200n + 1 000 000 = O(n) -> 1
200n^2 + n - 19 = O(n^2) -> 3
300n^2 + 12345n + 23 = O(n^2) -> 3
75n^3 + 4n^2 = O(n^3) -> 4
s + 3333 log n + 12343 n log n = O(n log n) -> 2
2^s + 1050s^2 = O(2^s) -> 5
2340(2^n) + 5000 (n^200) = O(2^n) -> 5
Time Complexity of Algorithms:
The worst-case time complexity would be an upper bound on the number of operations that an algorithm does to solve a problem with an input size of s.
Have a good day,
Belinda.
No comments:
Post a Comment