Question: Suppose that Algorithm A has runtime complexity O ( n ^ 2 ) and Algorithm B has runtime complexity O ( n log n )

Suppose that Algorithm A has runtime complexity O(n^2) and Algorithm B has runtime complexity
O(n log n), where both algorithms solve the same problem.
(a) Assume you started both algorithms simultaneously, and assume that n =50. Is it possible for Algorithm
A to terminate before Algorithm B?
(b) Is it possible, that actual running time of A and B is the function n?
(c) Suppose we also know that Algorithm A has runtime complexity (n^2), and Algorithm B has runtime
complexity (n log n). In other words, runtimes of A and B are \Theta (n^2) and \Theta (n log n), respectively. How
do the algorithms compare when n is very large?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!