Over the course of the last two weeks, my experiences in CSC 148 have been completely dominated by trees -- binary trees, regex trees (some of which are unary trees), binary search trees, trees with linked lists-- and for much of that time, I felt at least a little like I was lost in the woods.
When we first saw trees in Week 6, the concept seemed fairly simple. Understanding the structure and terminology of trees-- roots, nodes, children, leaves, height, etc-- was easy with a picture of a tree in front of me. Things got a little harder when I had to applying the same concepts to TreeLists--which visually seemed much more complex than the trees they represented. Traversing trees by hand was almost fun (shout-out to whoever posted that traversal video featuring Paul Gries, who I singlehandedly credit with making me interested enough in computer science to be taking this course, which is currently kicking my ass)--and I was SO READY for a midterm question that asked me to reconstruct a tree given two traversals.
That question never did show up on the midterm--but lo and behold, there it was as part of e3. Figuring out the code to produce the tree was a little more complex, but still a fun logic problem. The strategy of working things out by hand and then asking, 'how did I know that?" really helped--for example, knowing that an inorder traversal traces left-root-right allows you to split the tree into left and right subtrees (with the root isolated by virtue of its place in the PREorder list)--and then realizing that if I'm applying the same process to each subtree, it must be a good time to apply RECURSION.
(About recursion: even if I'm still not a pro at knowing HOW to use it, I think I'm much better now at knowing WHEN to use it--baby steps, right?)
Having knocked e3a off my checklist in short order, I internalized the (very wrong) idea that e3b would have the same level of difficulty--initially challenging, but then I would just GET it. (I worked on that function for several hours. I never 'got it'.) I knew enough to use the 'height' function we had seen in class to get the depth of the tree, but I never did figure out a way to identify the individual elements in the longest path. Neither did any of the 5 other people I converse with in this class. I THINK this has to do with my insistence on evaluating trees from the root down, when really I should be working with recursive calls from the leaves on up, but I need even MORE time to work with this function to figure it out.
Disheartened by this experience with trees (and also by my time-crunched earlier experiences with A1 and A2.1), I was dreading sitting down to work on A2.2, certain that I would while aware every spare hour I had (and some that I didn't have) being frustrated with the functions.
Luckily, this was not the case. I sat down with A2.2 on Monday morning, and managed to knock off most of the work before my lab on Tuesday night. It was so nice to walk into that classroom feeling like I had a handle on things (by the end of the night, I'd lost the handle again, as my worst enemy, linked lists, joined forces with binary tree traversals to confuse me soundly). I even helped some other students debug their code! Mine wasn't perfect-- I couldn't get one of the examples from the handout to match a longer, more complex string--but at least I was ahead of the curve this time.
Thankfully, after much perusal of Piazza, I stumbled across this post, which COMPLETELY cleared up my misunderstanding of how regex matching worked and ALMOST caused me to shout 'YES' after I successfully completed my function in the back of another class whilst watching a movie.
Having submitted A2.2 several hours ahead of the deadline (what a nice change!), I'm breathing a little easier--for tonight. Tomorrow, though, and for several days after, I'll go back to the demanding task of climbing (and descending) trees in preparation for the midterm--which I expect is going to be MUCH more difficult for me than Test 1. Hopefully by the time Wednesday rolls around, I'll be equipped with the skills I need to find my way out of the woods.
No comments:
Post a Comment