What makes recursion hard

Jasterix - Sep 12 '19 - - Dev Community

I had my first technical interview this week. My only whiteboard question: complete my least favorite challenge, the dreaded recursion.

Prompt:

Create a function that accepts a number and returns the sum of of the Fibonacci numbers up to that number

Results:

Unsurprisingly, I wasn't able to pull off the recursion. In the stress of the moment fixated on that instead of solutions that don't use recursion. But since then I've been wondering why recursion is so difficult for me. This is what I cam up with:

  1. I don't know where to start
    1. Although I understand recursion theoretically, implementing it is a different case altogether
  2. My function never returned my base case
    1. Why? No idea
  3. Especially when it's a problem I've seen before, I fixate too much on recreating solutions I've seen
    1. In this scenario, familiarity worked to my disadvantage. Instead of going line by line, I got frustrated by what I thought the solution should look like
  4. Nerves and stress
    1. There's nothing more nerve wracking than writing what should be a valid solution only to get Range Error: Maximum call stack size exceeded
  5. Lack of experience
    1. As frustrating as failing can be, I do realize that these things- interviewing, solving unfamiliar challenges, even recursion- will get easier with more practice

Conclusion:

Three days after the interview, I'm still frustrated by my perceived lack of progress. But I also feel even more motivated to understand JavaScript concepts better. Instead of recreating code I've memorized, my goal is to

  1. Understand JavaScript is doing under the hood
  2. Be able to break complex problems into smaller ones
  3. Write code that does what I intend for it to

I also want to consume resources like this CSX video that focus on exploring programming paradigms

For now, though, I think it's okay to be a little disappointed in myself

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player