01:198:107 Lecture Notes - Lecture 12: Linear Search, Binary Search Algorithm
Document Summary
Cs 107: lecture 12: 2-d matrices, binary search. It helps to treat the recursive call as a black box - assume it does its job but don"t think about bow. The function doing the call (the caller ) waits. Has its own copies of its variables. When the callee returns, the caller continues from where the caller left off. N in current invocation record is 2, 2==1 is false so do else. Start ruler (in ir2) from the beginning. N in ir2 is 1, 1==1 is true, so print 1 star. Ruler in ir2 is done so return. N in ir1 is 2, so print 2 stars. Evaluate argument in calling ir: n holds 2 so n-1 is 1. Start ruler (in ir3) from the beginning. N in ir3 is 1, 1==1 is true, so print 1 star. Ruler in ir3 is done so return. Ruler (in ir1) is done, so return to command window.