Earlier quoted context omitted.
There aren't too many things to remember in order to be useful: - Operations that take the same amount of time regardless of the input are O(1). ie: 1+1 takes just as long as 10000+10000 (okay, not really, but it's a reasonable assumption.) - Doing a small sequence of operations runs in O(maximum of all operations). Doing 5 adds (which are O(1)) runs in O(1). Doing an O(n) operation followed by an O(k) (where k > n)…
Sorry, I should have been more specific: I understand the rules of Big O complexity, which you aptly summarized; the part I'm really curious about is " From there, you can pretty much combine these rules to analyze many algorithms. " It's not that the concepts are mysterious to me, but that making them a part of my learning habits has not come naturally.
I'm not sure if I'm still misunderstanding you, but here's an example of what I meant.
Say, for whatever reason, you want to populate a binary tree with k items of random data:
for(int i = 0; i
The inside of the loop runs in O(log(n)) time because O(log(n)) > O(1). We're doing it k times, so the total time is O(klog(n))Now, if you wanted to do this for m trees:
for(int j = 0; j
We already know that the inner loop runs in O(klog(n)). Since we've just added a loop around that, it's easy to see that the whole thing runs in O(mklog(n)) time.