Courses‎ > ‎AP Computer Science 2‎ > ‎Konstantinovich‎ > ‎


posted Feb 1, 2017, 7:55 AM by Samuel Konstantinovich   [ updated Feb 1, 2017, 7:55 AM ]
Goal: Miracles (recursion)

Yesterday we talked about:
  1. Tail Recursion
    • No pending operations  e.g. 1 + foo(n-1)  //the 1 + has to wait for the foo, so it would be pending.
    • Partially computed answer is stored as a parameter 
    • Java does not have tail recursion optimization: tail recursion still blows the stack after less than 11,000 calls, much less if you have more parameters.
Today We will develop some algorithms together:
sumDigits(int n)
isPrime(int n)

Make a new github repo for this semester's homework.  MKS22X-HW or something similar. 
You will make a new folder on the TOP LEVEL OF YOUR REPO* for each homework starting with a 2 digit homework number. *Do not make a folder and put all of your homework assignments into it. The repo IS your "folder".


2. Complete the recursion1 problems on codingbat:
changeXY, array6, allStar, countPairs, StringClean, nestParen