Wednesday, 5 March 2014

Brian's CSC148 SLOG # 8

Hello! How is everyone doing?
Welcome to my eight SLOG post.

This week has been quite alright! Term papers have been given back and I achieved 77.5% (B+) which is wonderful. I was expecting a grade in the B range but on the next test and the final exam I will be working harder to achieve even higher!

What's new in this SLOG post? 

This time I will be discussing:
  • A little bit of assignment 2 
  • Challenging concepts I am facing in CSC148
Without further ado, let's begin!

Assignment 2

Assignment 2 is all about creating Regexes and parsing Regexes and matching them with strings. As of now, we are only responsible for part 1: creating Regexes and part 2: parsing Regexes while matching them with strings will come later.

So what are Regexes? Regex is an abbreviation of regular expression which is used in different programming languages and other utilities to match entire classes of strings. For this assignment we will only be dealing with  regexes over the ternary alphabet {0, 1, 2} which is a non-empty string that consists of the symbols '0', '1', '2', 'e', '|', '.', '*', ')' and '('.

I managed to get insight for A2 by first creating a master class and subclasses that will later handle the creation of a regex such as ('2'|'3'). What information about regexes can we use to start coding our classes? By looking closely, we can tell that it has similar properties to a how trees are constructed. The nodes '0', '1', '2' and 'e' are the leaves and have no children and by knowing this, we can consider the bar '|' as the parent node. Comparing to a tree example such as: Tree(1, Tree(2), Tree(3)), we know 1 is the parent node, or root and 2 and 3 are the leaves that have no children. A regex can be represented similarly like so: Regex('|', [Regex(1), Regex(2)]).

With the insight that regexes can be expressed similarly like trees can in programming, I have managed to finish part 1 of assignment 2 which I will discuss in more detail next week. The deadline has been extended this week so I don't think I am able to share my full solutions just yet but look forward to my next post as I will explain be explaining it with great detail!

Challenges

University has been challenging for computer science courses. Very often I have had to take lots of time to consider how to approach new concepts and sometimes I feel that I am in the midst of somewhat understanding the new concepts but not yet fully. Comprehensions and recursion are the challenges for me right now. Comprehensions are very difficult for me because they are written quite differently from how I'm used to coding. Recursion is somewhat difficult for me. For easy problems I have no problem using recursion to solve them but for more complex ones, I struggle for long periods of time. The tough problems for me are usually a mix of comprehension and recursion in a single function. Asides from this, I can handle recursive functions at a good level. The only question is, whether or not I can understand comprehensions + recursion together before the end of the semester. I certainly hope so!

Thanks for reading my eight SLOG post! 
Have a wonderful week.

2 comments:

  1. Good explanation of regexes, I took a very similar approach to the first part of A2. Time to tackle part 2!

    ReplyDelete
    Replies
    1. Thanks Ben! Let's do our best for part 2.

      Delete