Algorithm 1 has running time t1n 41nlogn 37n 19 Algorithm

Algorithm 1 has running time t1(n) = 41nlogn + 37n + 19. Algorithm 2 has running time t2(n) = n2 + 5n + 7. For what values of n is Algorithm 2 faster than Algorithm 1?

Please explain throughly how you graphed this and solved it and provide the graphs.

Solution

Answer:

t1(n) = 41nlogn + 37n + 19

t2(n) = n^2 + 5n + 7

If we check the time complexities of both the functions , t2(n) has worst complexity of O(n^2) which is greater than t1(n) with O(n) worst case complexity.

t1(n) = O(t2(n))

t1(n) < = t2n

41nlogn + 37n + 19 < = n^2 + 5n +7

n^2 + 5n + 7 - 41nlogn - 37n - 19 = 0

=> n^2 +32n -41nlogn -12 = 0

This is the equation from where we can give higher values of n to check the graph deviation.

Algorithm 1 has running time t1(n) = 41nlogn + 37n + 19. Algorithm 2 has running time t2(n) = n2 + 5n + 7. For what values of n is Algorithm 2 faster than Algor

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site