0

Afternoon guys and gals,

First and foremost, I hope all is well. I have been reviewing CLRS 3rd edition and was wondering exactly what is the constant value in regards to algorithm. (a.k.a where is it visualized/manifested in the code)

For instance, CLRS 3rd Edition describes how “insertion sort, takes time roughly equal to c1n2 to sort n items, where c1 is a constant that does not depend on n. That is, it takes time roughly proportional to n2.” (p. 12)

  • Is the constant derived from simply how you implement/modify you insertion sort algorithm? Any specific example would be tremendously helpful.
  • Also, are we to assume that the constants will always/eventually be less than n2 and thus we can ignore it?
  • 1
    The point isn't what it is, the point is that it's constant, i.e. it doesn't change with the value of `n` (the size of the input). In the real world the constant part may in fact be so large as to render an algorithm unusable, but that does not affect the theoretical analysis. – 500 - Internal Server Error Dec 26 '21 at 22:58
  • @500-InternalServerError, thanks for clarification! Makes much more sense now. – Edmund Leibert III Dec 26 '21 at 23:27

0 Answers0