Solved 1 Answer
See More Answers for FREE
Enhance your learning with StudyX
Receive support from our dedicated community users and experts
See up to 20 answers per week for free
Experience reliable customer service
Worst case time indicates the longest running time performed by an algoritm given any input of size n . The worst case time guarantees that the algoritm will finish in the indicated period of time. So for this function worst case time is N^2 because input is any value of n> 2.  By looking at the function we can say that it will take order of n time because there is loop present in the function which is executive for n times including the condition check, so minimum it will take O(N) time.There are two loops present so we can know that it will take more than O(N) time. But we have to give worst case time so for safe side we will take N^2 because it will be true for any value of n. ________________________________________________________ For return value- In question it is given that n>2. So we will start from n=3. If n=3 Initial value of s is 0. q s 1 0+1=1 2 1+2=3 3   Since q became  equal to n , we will come out of the first for loop. Now entering in second for loop-    Initial value of s is 3. r s 3 3-1=2 2   Value or r became 2 se we will come out of loop . Retrun value for the function is r*s= 2*2=4 _________________________________________________________ If n=4 Initial value of s is 0. In first loop q s 1 0+1=1 2 1+2=3 3 3+3=6 4   q became equal to n se we will come out of the loop. Second for loop- Initial value of s is 6 r s 6 6-1=5 5 5-1=4 4 4-1=3 3 3-1=2 2   r became 2 so we will come out of the loop r=2, s=2 return r*s=2*2=4 If we continue checking for other values of n we will get constant return value 4. So for thid function fun(n) the return value expression is 4. Hope you got your answer. Thank you 😊 ...