July 30, 2015 Log No. 307

I Walk This Recursive Road…

So today was recursion day, which no matter how many times I learn it, is usually a bit of a headache. Today though I do think it went a little smoother than usual, partially because:

1) I think this is my 3rd or 4th time going through it so I’d like to think I’m a little better every time,

2) also the same kinda problems show up (Fibinocci, exponents, mergesort, etc) so I should at least be able to remember something, haha, and

3) Ruby/pry actually makes it pretty easy to follow the stack calls when things go awry.

Managed to get through most of the exercises; only thing was that I was usually so relieved to get the code working properly that when I compared to the solutions, I realized I left a lot of extraneous code. It’s because it’s recursion! I get worried that any small change gets magnified in the recursive calls and so I’m scared to touch anything, aha.

Didn’t quite finish the subset implementation by the time I left class, but after a couple hours of clearing my head and NOT thinking about recursion, it became a lot clearer and took only 15 min to debug and get working. Mostly it was just << messing up the arrays–with the shovel, I had all sorts of weird Frankenstein subsets being returned (some were even longer than the original array–how does that even happen), whereas changing them all to += pretty much solved my entire issue. Lesson learned: don’t use shovels on things that may be getting modified from several different sources! Just create a clean new array!

Leave a Reply

Your email address will not be published. Required fields are marked *