So far, we have learned to work with trees in our labs, lectures, and assignments. One of the trees we worked with, which I found interesting, was a binary search tree. A BST has an arity/branching factor of only two. Every node contains a value for which every node on its left subtree, the values are smaller than the parent value, and every node on its right subtree, the values are greater than the parent value. This comes in handy, as seen in the lab, when trying to find the number of nodes that are less than a certain value. We then combined our knowledge of binary trees with linked lists in this weeks lab when we created linked lists of an inorder traversal of a binary tree. This was difficult at first, but was solved by using a recursive call on a function within a function. Although difficult to grasp at first, through practice with different methods that included recursions, the task got easier, though I still need to work on it more.
I also had more practice with recursion in the assignment due this week where we tested for valid regular expressions and created the regular expression trees for each of the valid string expressions. The most difficult part of this assignment to me was figuring out how to determine a valid regular expression from a string input as there were many regexes within the main regex. It was difficult trying to find out which of the '.' or '|' was part of the first regex. The next difficult task was trying to find with regex was equivalent to which string. This was solved by using different if statements and lots of recursion.
In conclusion, this week has been fairly difficult and busy, but helped me with recursion.
No comments:
Post a Comment