Question
Often mathematical functions are used to express the runtime of algorithm. You are being given five different algorithms, whose runtimes are expressed by the following
Often mathematical functions are used to express the runtime of algorithm. You are being given five different algorithms, whose runtimes are expressed by the following functions. Each function varies with N, where N is data size.
T1(N) = N2.5, T2(N) = NlgN (lgN = log2N = log(N)/log(2) ), T3(N) = (1.25)N, T4(N) = N4 and T5(N) = NN
Arrange the algorithms from best to worst (assume N values should be sufficiently large so that you can compare different runtimes).
Write a C++ program to implement each of those functions, and generate a table by varying N from N = 10 to N = 100 in steps of 10 (i.e.) N = 10, 20, 30, 40 etc.
The program should output the following:
N T1(N) T2(N) T3(N) T4(N) T5(N)
10 .. .. ..
20 .. .. .. .. ..
Etc.
.. are computed values from the code.
Make sure to have the return type for each function is float and input N is integer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started