Algorithms A and B solve the same problem. Time complexity of A is in O(n^2)
and that of B is in O(n). Which among the following can you guarantee?
O A is having less executable instructions than B
O A is having more number of functions than B
A is having less number of functions than B
A is having more executable instructions than B.
Answers
Answered by
6
Answered by
2
A is having more number of executable instructions than B.
Explanation:
- The time complexity of an algorithm depends on the number of operations it performs and not the number of statements it has.
- For example: the time taken for an algorithm that prints an array in one print is less than the time taken by an algorithm that runs a loop over the array to print an element one at a time.
- Hence, for given algorithms of the same problem A has higher time complexity because it has more number of executable instructions than B.
Similar questions