Estimate the order of growth of algorithm from run time and ratio of change -
i'm beginner practising algorithms. below list represents algorithm ran , recorded times , ratio of change. i'm not sure how figure out order of growth list. factors have consider? appreciate explanatory answer.
n |seconds | ratio | log(base of 2) ratio --------------------------------------- 512 0.12 4.14 2.05 1024 0.49 4.24 2.08 2048 2.08 4.24 2.08 4096 8.83 4.24 2.08
compare times smallest input various larger inputs:
- a 2x increase in n (512->1024) results in 4x increase in running time.
- a 4x increase in n (512->2048) results in 16x increase in running time.
- an 8x increase in n (512->4096) results in 64x increase in running time.
from this, can extrapolate kx increase in n result in k2x increase in running time, indicating o(n2) algorithm.
Comments
Post a Comment