An algorithm is analyzed and found to take time as a functio


An algorithm is analyzed and found to take time as a function of n, T(n) = 2n^2 + 5n What is the order of the algorithm? Find a c_0 and n_0 to prove your answer

Solution

Answer:

T(n) = 2n^2 + 5n

Now , as we can see the highest power in the function is n^2 . Therefore its order is n^2 = O(n^2)

b) Now we know the big O definition :

f(n) = 2n^2 + 5n

f(n) < = c0 * g(n)

2n^2 + 5n < = c0 * n^2

let c0 = 1

2n^2 + 5n = n^2

=> 2n^2 + 5n -n^2 = 0

=> n^2 + 5n = 0

=> n( n + 5) = 0

=> n = 5

Therefore c0 = 1 , n0 = 5.

 An algorithm is analyzed and found to take time as a function of n, T(n) = 2n^2 + 5n What is the order of the algorithm? Find a c_0 and n_0 to prove your answe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site