A small mistake i've seen in your post is in the example of giving forks. The initial program is O(n) no O(n^2). That's because the first loop is constant (it is not looping over n).
I suggest you to correct that, because that example, for someone who just started in algorithm analysis, could induce to think that every program with, let's say, k nested loops will be at least O(n^k), when that it is not true.
Out of that, great introduction to this awesome subject that is algorithm analysis!
Greetings :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello there!
A small mistake i've seen in your post is in the example of giving forks. The initial program is
O(n)
noO(n^2)
. That's because the first loop is constant (it is not looping over n).I suggest you to correct that, because that example, for someone who just started in algorithm analysis, could induce to think that every program with, let's say, k nested loops will be at least
O(n^k)
, when that it is not true.Out of that, great introduction to this awesome subject that is algorithm analysis!
Greetings :)