DEV Community

Discussion on: A coffee-break introduction to time complexity of algorithms

Collapse
 
pramodkirchki profile image
pramodkirchki

I really appreciate the time in writing an article like this, while keeping it creative and interesting.
I am a newbie here in analyzing the complexity of the algorithms. But, isn't the last 2 giveForks example O(n) complexity? From the referenced Wikipedia article, there are some examples which are constant time complexity despite having multiple for loops.

Regarding the time improvement that you see, might it be because the second code is somehow cache-friendly possibly?