<p>Taking the AP CompSci exam really soon, and still struggling with finishing the MC on time. It's really just the recursion problems and nested loops that get me (the latter because I cannot count very well). With recursion problems, my technique is to work through the problem step by step. For example, </p>
<p>public int r(int n){
if(n>0)
return n + r(n-1);
}</p>
<p>I'd do r(4) = 4 + r(3), r(3) = 3 + r(2), and so on, and then substitute back. (Well, for a problem this simple I'd probably recognize what it was, but this is just to illustrate my technique.) This works for the most part, but I am wondering if there is any quicker way to do these problems? Doing every step of the recursion really eats up my time. </p>
<p>For loops, and nested ones especially - I have a lot of trouble figuring out how many times each one iterates. I always get confused with < and <= ... If someone could explain to me how to figure it out very quickly, it would be much appreciated. </p>
<p>If you have any other tips and tricks pertaining to other AP Comp Sci topics, please share!</p>