Exercise 3 and Assignment 2, Frustrations and Success

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.


One thought on “Exercise 3 and Assignment 2, Frustrations and Success

  1. I had a heck of a time figuring out part B of E3. I actually prefer using Stacks instead of recursive code (except in some rare cases) because they are so simple but they can be used in so many ways with Linked Lists and BSTs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s