We study how an algorithm’s running time grows in relation to the growth of its input size. Therefore, if an algorithm’s runtime grows at a linear speed in relation to its input size, when the runtime for a specific algorithm is 15 time units for an input of size 10, then it will be 30 units for an input size of 20 and 45 units for an input size of 30. If an algorithm’s runtime increases at a rate of n (n is the input size and the algorithm runs for 4 time units for an input size of 5, what is the runt for an input size of 10?
Expert Answer
The time complexity for the algorithm for which the runtime increases at the rate of n2 will be Quadratic. The running time is proportional to the square of n. When the input n doubles, the running time increases by n*n.
Therefore it is given that n=5 and it doubles
hence the running time would be 4*4=16 time units.
Thanks.