William Wen
1 min readMay 10, 2022

--

There are a few issues with recursion.

  1. It appears more intuitive, but sometimes isn’t. IMO, more complicated than necessary for a binary search.
  2. Basic recursive approach is easy when the number exists, but when the number doesn’t exist, how does a recursive approach find the next smallest number? A lot of interviewers get tripped up on that. You end up with a less beautiful recursive function call.
  3. A lot of developers forget to write the helper function.
  4. They also end up writing preconditions twice. Once in the helper function and one more time in the recursive functions.
  5. Suppose the array has a trillion numbers, recursion uses a lot of stack space which is not necessary with an iterative solution.
  6. The recursive solution is more lines of code for the purpose of a one hour long interview.

I find the iterative solution gives me fairly good hire/no-hire signals, without the candidate getting tripped up by recursion.

--

--

William Wen
William Wen

Written by William Wen

25 years in tech | 13 years @ Google | Tesla Investor since 2013 | www.linkedin.com/in/wil-wen | twitter.com/wilwen2

Responses (1)