Provide the algorithmic efficiency for the following tasks J
Solution
A.
In this pseudo code only once a condition is checked, so this will take constant time irrespective of value of n. SO the time complexity T(n)=O(1).
B.
Suppose the size of the list is n, then the loop will run n number of times to search the element linearly, so the time taken in searching the element will be dependent on n and in worst case considering that the element will be found at last. It will take order of n time to search the element. So time complexity T(n)= O(n)
C.
Suppose the size of the list is n, then the loop will run n number of times to compare smalll with every element linearly, so the time taken in finding the smallest element will be dependent on n. It will take order of n time to find the smallest element. So time complexity T(n)= O(n)
D.
In this program if the length is same of both the lists, suppose n is the length then the time complexity T(n)=O(n).
