2015-02-05

posted Feb 5, 2015, 8:37 AM by Samuel Konstantinovich   [ updated Feb 8, 2015, 6:41 PM ]
Goal Recursion day 2.

Yesterday we talked about:
  1. Base case
  2. 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:
int sumDigits(int n)
boolean isPrime(int n)

Comments