discrete mathComplexity of algorithms The best and worst cas

discrete math-Complexity of algorithms-

The best and worst case time complexity of an algorithm we
are using is O(n log2 n). For an input of size n = 1000 the algorithm
ran in 25 seconds. Approximately how long should the
algorithm run for input size n = 4000?

please be as detailed as you can.

Solution

The running time of O(n log2 n) is directly proportional to n log2 n.

i.e., T(n log2 n) = cn log2 n

For n =1000, the running time is 1000 log2 1000, which is given as 25 secs.

i.e., the running time when input size n = 1000 is 9965.78 (approx.).

Thus, for n = 4000, the running time is 4000 log2 4000,

which runs approximately 100 secs.

discrete math-Complexity of algorithms- The best and worst case time complexity of an algorithm we are using is O(n log2 n). For an input of size n = 1000 the a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site