Why do we use the ending letters to build or sequence instead of the beginning letters from the last lesson?
-
Module 3 Day 11 Challenge Part 3
How come for the example in Day 10, we represented "a sub n" or "a sub n-1" as the possibilities we START WITH when trying to find a recursive pattern. But for Day 11, instead we represent "B sub n" or "B sub n-1" as possibilities we END WITH. On a real test, how would we know when to use which strategy? And how were you guys able to determine which one would suit better for each problem? Thanks!
-
@joyfulgazelle
That's a great question! If I understand you correctly, you're asking why the Day 10 problem's recursion has to do with tilings you "add on" to, whereas in Day 11, the recursion relates to what color the string of beads ends with.Actually, both times, the main strategy is to add something onto something else you "start with": we add a bead to a preexisting strand, we add a tile to a preexisting tile sequence. They are both possibilities you "start with", but for the Day 11 problem, there's an extra complication: the color of the last bead matters when defining a recursion (as explained in the video). That's why you need two variables for the recursion (B and W) as opposed to just one variable, in the Day 10 problem, where there's no restriction like that (it doesn't matter whether the rightmost tile was a square or a rectangle. It's fine to have, say, two square tiles next to each other. All that really matters is filling in the 1xn area).
So on a real test, it might be helpful to ask yourself whether there is a restriction like in the beads problem - if so, you may need more variables for the recursion. However, the big picture is still the same! No matter what, with recursions, you're trying to build new cases from smaller ones.
Hope that helped!
-
@vibrantraccoon That's helps. Thanks!
-
@joyfulgazelle No problem!
-
@audrey Thank you!