2015年3月28日星期六


Week 11   Revisit an Earlier SLOG Posting



This semester is going to finish and we just left only one-week lecture. I looked back to all my postings. I realized, in retrospect, that the recursion used in almost every single key data structure we learnt (List, Tree, Binary Tree, etc.) Therefore, this entry I would like to revisit my slog week 5: tracing recursion, and talk about recursion more.

l   Further understanding on recursion

On my previous slogs, my fundamental definitions and understanding about Recursion was basically correct, but a little narrow. At that time, I only learned the tracing recursion and recursive codes in the lists. And up to now we touched the recursive application in many data structures, such as the Tree, Binary Tree, LinkList and so on. Recursion is a type of mathematical thinking, which can be flexibly used in varies kinds of problems, not just in computer science.


l   Progress from then on  

From the previous slog, I wrote: “the biggest hardship I encountered was writing recursion myself. I found a stupid way to overcome, that was, used for loop first, and then transferred it to recursion approach.” At that time, I felt confusion and not self-confident on coding recursion. I could only indirectly think the problem, not recursively. But this injudicious method was limited to simple questions. What’s more, it lost the real meaning of using recursion, which is solving problems efficiently and conveniently. I attempt to flatten the data structure, which produced redundancy in running time. However, due to all kinds of applications and a number of practices on labs or assignments, I got a clearer sense on whether a recursion should be used, and obtained stronger skills to apply recursion into practice.
Assignment 3 this time is about this problem. It is aimed at building our skills of coding efficiently and avoiding repeating. In the beginning, I just flattened the entire tree into a list at the outset and then traversed the list instead of traversing the tree. That was because it was really easy to think and to transfer into codes. But after forbade by professor, I tried to keep track of the game states I've seen so far and to traverse the tree directly, which was really painful to me and I always couldn’t get out of my inaccurate pattern. Thanks for the discussion on the piazza and professor’s office hour, we found the way to resolve them gradually.

For instance, counting_distinct_node:

        As can be seen in diagram, the old approach I used was to return all the nodes of the tree into a list first, and then picked the distinct nodes from that list.


        The method I improved later was to building an inner helper function to recur the tree, and then it produced the outcome straightforward in the main function. It is worthy to mention that I used data structure “set” instead of “list”. Because when you add two same values in the set, it will keep only one of them, which would be very efficient.

l   Reaction to other’s slog

I really appreciate Christian Garcia’s posting, since they are quite clearly and readable with excellent paragraph distribution and some interesting pictures.

He also chose to revisit a slog of recursion, same as me. He summarized lots of helpful frameworks and their characteristics, which I agreed with. However, these frameworks will not help a lot when we encounter the complex questions. In my opinion, we do not necessarily dwell on the frameworks of every step. The most important thing is to understand it, and recreate it by codes.

2015年3月23日星期一

Week 10   Term Test 2

We didn’t learn too much thing just extension of Binary Search Tree this week because of the big event: term test 2!

  • Term test 2

1. Preparation

Before term test 1, I spent a bunch of time on slides and lecture examples, and the most practice I did was on the past tests, which maybe emphasized differently from this term. Although I did exercise in labs, I didn’t rewrite it. Hence, I lacked a lot of exercise on key points. When I was doing term test 1, I found a number of problems were familiar with lab’s examples. However, what made me regret was I didn’t value labs that much, and even didn’t correct my answers with professor’s. Therefore, due to thinking from beginning, I wrote slowly, and I could not make sure whether my answers was correct. Gradually, I lost my confidence and testing strategies. Awful time arrangement and self-doubt emotions lead to my unnormal behavior in term test 1.
Consequently, I learnt a lesson from test 1. This time, revising and rewriting lab’s exercise cost my majority of reviewing time. I found redoing labs not only stimulated me apply what I learnt into real problems, but also helped me solidify and obtain better understanding of lecture knowledge. What’s more, I did not give up to review other materials because of labs. I still distributes reasonable time to lecture slides and others.

2.Behavior during the test

“No pains, no gains.” Based on hard practice and deep understanding on previous labs. For last two main parts, writing codes, I did really well. The second question really resembled to the example I copied on the cheat paper, so I finished rapidly. Although there is no similar examples to the last question. I have already mastered the LinkList through lab exercise. There is no doubt that I addressed this problem smoothly.

Nevertheless, what surprised me was I was stuck on the first question! I was confused about the definition on branching factor. When I checked after the test, I realized that I had an entirely wrong impression on branching factor. The branching factor is the max number of children for any node, which means any nodes’ children number cannot exceed this branching factor. More specifically, branching factor is a bound and a tree does not has a exactly number as is branching factor. However, I thought branching factor was the max number of children of one of the nodes.

The test asked me that suppose we have a tree of height 3 with a branching factor of 3, the least number of nodes this tree would have is____?
Because of the incorrect understanding in definition, I answered 5. I thought at least one level of three has 3(branching factor) children, and other two has one. (3+1+1 = 5) The correct answer is 3(e.g. the root, with a right children that also has a right children).
Maybe I focus too much on labs and lecture examples, but ignore the basic simple definition.

3.  What I learnt from this test

In the final, I will pay more attention to the basic definition, even detailed knowledge. On account of test strategy, I will do my best to calm my self down during the test and allocate time reasonably. As to preparation, I think practice enough is the most important!

  • Reaction on classmate’s slog


Yahui Liu was in a same dilemma as mine in term test 1. I want to
congratulate her that she realized the importance of the labs’ exercise finally. It is still not late, because the worst test is only accounted for 6%, whereas final takes up to 40%! However, my suggestion is “don’t think too highly of labs.” That is because professor will test us more comprehensive knowledge and emphasize to test how we understand the lecture content, but not the similar problems with labs any more. It is better for you to look through all the lecture material to do the overall review.