Choosing

Choosing: 5,000 Folders Deep: Recursion or a Loop?, Asking the Same Question Twice: Memoization.

Updated

  1. 5,000 Folders Deep: Recursion or a Loop? (Journeyman): Keep the folder tool working on a folder thousands of levels deep, where recursion runs out of call stack: why a bigger limit and a plain loop both fall short, how a loop with a pile of its own does the job, and how to choose between recursion and a loop for any task.
  2. Asking the Same Question Twice: Memoization (Journeyman): Speed up a recursive function that answers 10 stairs at once, 40 in half a minute and 50 in about an hour: why a faster computer and a loop with your own stack don't help, where the time really goes, and how writing each answer down, memoization, makes it instant.