Memorizing Algorithms
Learning some algorithms, starts with memorization.
A lot of smart people will tell you don’t need to memorize algorithms, you have to learn them. However, memorizing them helps you to learn them sometimes. Also, once you’ve memorized some, then you have learned them; in some ways. With the fibonacci sequence, it helps to memorize it, explain it, and write it in different ways. Look at other solutions, and write those.
Nobody knows the answer to the fibonacci recursive solution, who hasn’t seen it before.
When you ask the question, your checking that:
- the person has seen this before
- the person is able to reproduce this formula
Nobody is going to just figure this out. However, once they learn this, then can modify it to work for other types of problems, like staircase, rob houses, etc.
You need to learn how to generate the fibonacci sequence. You need to memorize the formula if the concept doesn’t make sense to you. F(i) = F(n-1) + F(n-2).