Computer Science, asked by kshitijmagare, 4 months ago

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 Oreki
6

\textsf{Given, }\\\textsf{\hspace{1em} Algorithms A and B solve the same problem also,}\\\textsf{\hspace{1em} Time complexity of A is in $O(n^2)$ and that of B is in $O(n)$}\\\textsf{\hspace{0.5em} So, we can guarantee that \textbf{A is having more executable instructions than B.}}

Answered by priyarksynergy
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