DEV Community

Discussion on: Insertion Sort with Javascript

supunkavinda profile image
Supun Kavinda Author

You are correct, in general it is called order of growth.

Order of growth is used to simplify the process of analyzing, which converts an(2) + bn + c to n<sup>2</sup> for our ease. So, for the worst case of insertion sort the time complexity (running time) can be simplified to n2 (notated as Θn2)

What we do is, assume the lower-order terms are relatively insignificant for large values of n. And, we drop the constants too for the same reason. It is all for making the analyzing process easy for ourselves.

For small inputs, the running time may depend on lower-order terms and constants. But, when the number of inputs increase, it almost depend on the leading term.


yuripredborskiy profile image
Yuri Predborskiy

Great explanation, thanks!