2014年3月16日星期日

week9


This week was a little busy. I needed to finish my assignment 2 and exercise 3. Especially for assignment 2, it is difficult. When I got the handout, I even did not know where I should start. After asking question on piazza and discussing with my partner, I was on the right track. Nearly every function needs the recursion. For example, in is_regex, I need to write helper functions to distinguish different types of regex. In the regex that has the form ‘(‘ + ‘r1’ + ‘.’ + ‘r2’ + ‘)’, I need to know whether r1 and r2 are also regexes, so this part needs using recursion.

The lab of this week let me know the importance of using recursion. When we wrote the function count_less, it was easy to implement by using recursion. However, if we are not allowed to use recursion, we need to think other ways. It took me much time to get the result. I used the class Stack to save the numbers. Comparing with using loop, recursion is easier.

没有评论:

发表评论