Please give the answer and the reason to both questions espe
Please give the answer and the reason to both questions especially question 4
Suppose that the method p has a return type of double and requires time O(r) time, where r is independent of i. If we let n = j.length, what is the time complexity of method b in the worst case? O(n) O(nr) O (r) O(n2) O(r log n) Again suppose that the method p has a return type of double and requires time O(r) time, where r is independent of i. If we let m = k.length, what is the time complexity of method a in the worst case? O(mr) O(r log m) O (mr log m) O(r^2 log m) O(mr^2)Solution
Q3)
method p has => O(r) time complexity
In method b, for loop runs n times and method p called n times
So, Overall time complecity: O(n)*O(r) = O(nr)
Option B is correct
Q4)
method p has => O(r) time complexity
In method a, for loop runs m times and method p and b called logm times
So, Overall time complexity = O(logm)*(mr)*(r)
= O(m*r^2*logm)
There is no option
Please let me know in case of any issue
