- #1
surfy2455
- 3
- 0
*solved
Lets say we have three algorithms, which include the following complexities 200n, 3n^2, 2^n-1. What would be a combined algorithm which is efficient?
Let me know if I'm on the right path here.
100n+3n^2 + 2^(n-1)
=log(100n)+log(3n^2)+log(2^(n-1))
=[log(100) + log(n)]+[log(3)+log(n^2)]+[(n-1)*log(2)]
=[log(100) + log(n)]+log(n^2)+(n-1),exclude constants
=log(n)+2log(n)+n
=(3log(n)+n)
The efficiency of the combined algorithm is O(3log(n)).
Homework Statement
Lets say we have three algorithms, which include the following complexities 200n, 3n^2, 2^n-1. What would be a combined algorithm which is efficient?
Homework Equations
The Attempt at a Solution
Let me know if I'm on the right path here.
100n+3n^2 + 2^(n-1)
=log(100n)+log(3n^2)+log(2^(n-1))
=[log(100) + log(n)]+[log(3)+log(n^2)]+[(n-1)*log(2)]
=[log(100) + log(n)]+log(n^2)+(n-1),exclude constants
=log(n)+2log(n)+n
=(3log(n)+n)
The efficiency of the combined algorithm is O(3log(n)).
Last edited by a moderator: