2 ms·
It's not a dumb question, this idea is covered at the beginning of every data structures class and is described as Big O Notation. The difference is the growth
by mason240 13y ago
It's not a dumb question, this idea is covered at the beginning of every data structures class and is described as Big O Notation.
The difference is the growth rate.
for(..){} for(..){} will grow linearly, or O(n).
Iterating over 10 items will be 20 loops, while iterating over 11 items will only be 22 loops.
for(..){ for(..){ } } grows exponentially, or O(n^2)
Here iterating over 10 items will be 100 loops, and increasing n by 1 (to 11) results in 121 loops.
Typically it preferably to user O(n) over O(n^2).
This probably explains it better than I can: http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notat...
- redxblood 13y agoThanks a lot! Explained really well ^^