What is the worst case running time of the algorithm below E

What is the worst case running time of the algorithm below? Express your answer in Big O notation. Show your work. int foo (int k, int n) {int result = 0 for (int i = 0; i

Solution

The given function has two for loops, first for loop will run k times while other for loop will n times. Since both of them are separate loops, therefore time complexity of the function will be O(k) + O(n) which is O(max(k,n)).

Hope it helps, do give your response.

 What is the worst case running time of the algorithm below? Express your answer in Big O notation. Show your work. int foo (int k, int n) {int result = 0 for (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site