Friday, March 21, 2014

Week 10: Assignment 2

Assignment 2, which dealt with regex functions, was finally finished yesterday.  Initially, I had quite a bit of trouble thinking about how to approach regular expressions, especially the is_regex and regex_match functions.  My first plan for is_regex was to parse the string at every single operator, but I realized that it would only slow down the function and that I had no idea how to go on from there; I had no idea of how to find the outermost regex operator.  Later, I thought of counting the number of opening and closing parentheses to keep track of each "layer" and actually found this to be very helpful and intuitive, so I stuck with that method and managed to make is_regex work.  As for regex_match, it was more of sitting down and outlining the function first rather than diving straight into writing.  The function basically consisted of if-else statements for every possible operator; the already-verified parts of the string argument was cut off and the remaining unverified parts was fed through each recursive call.

For the most part, Assignment 2 went by pretty smoothly after I took the time to understand the basics of each function's purpose and made a pseudocode outline.  After this project, I really do hope to read more on regular expressions and exactly their uses are.  In other news, we have started to cover runtime analysis and big-O problems in class; I've done a bit with this in 165, although there is still much I need to work on with regards to runtime analysis.  By the end of this course, I want to be at a level where I'm most proficient or can at least determine the big-O of a piece of code.

No comments:

Post a Comment