Skip to content
loading...

re: Big-O Notation: Beginners Guide VIEW POST

FULL DISCUSSION
 

Awesome Post! Really helped my general understanding of Big O. that said, I did have a question regarding the O(n2) definition.

If you have a function that has 3 nested for loops, as opposed to 2 (as you have in your example) does the complexity then become O(n3)? I can't seem to see anything online that would say so...

 

Hi! Thanks, I really appreciate it!

Yes, absolutely. If you make your for-loops grows with the same input, you can have something like an array of 4 spots and go through him three, four or five times growing the complexity in something like O(4 3, 4, 5 ...n ).

If you're going in a recursive way, the complexity it doesn't is O(n n ) and becomes exponential.

 

awesome!
That makes a tonne of sense! Thanks for the reply 😊

You're welcome. I'm glad to helped you 🙏

code of conduct - report abuse