Exercise 3 and Assignment 2 were challenging. I quite enjoyed coding their functions, but I won’t lie and say I wasn’t partially defeated by Assignment 2. I know there was an easier way of coding all_regex_permutatins, and I was determined to figure it out on my own before the deadline of the assignment. Unfortunately I could not, and had to submit the ‘find-all-permutations-and-check-them’ method.
That being said, coding regex_match and seeing it work was a real joy. It really was much fun. The biggest hitches I had with that function had to be handling DotTrees and StarTrees, but I got them to work, and my tests completed. Though I’m not sure I successfully tested every scenario of regex, so I’m hoping all goes well during the marking.
Now when it came to Exercise 3, part A was a breeze. PArt B took some thinking, however. Finding out how I wanted to utilize a helper function to identify the deepest paths was the trick. It really m ade me appreciate the use of helper functions in a function itself, especially for recursive purposes. It’s really interesting though – because Stacks (an iterative method) and recursive functions can both achieve the goals of some functions, but deciding which one to use is a bit of a grey area for me.
I’ve usually favoured the recursive code over using Stacks, but I always wonder if it would be terrible to use Stacks instead – considering they’re such an awesome ADT. Then again, I don’t even use an explicit Stack. I just create a list and treat it as a Stack for the purposes of my function.