I have focused mainly on assignment 1 this week and I am very glad to see things pulling together. The weather is also a lot better, and I am very excited about it.
This week we talked about trees in class, the names of different parts of trees, and simple definitions on the parts. For example, each non-root node has exactly one parent.We also went over the code for preorder traversal, in-order traversal, and post-order traversal, and compared the differences between the three different ways to go over the root.
I think I will definitely need some time to understand the parts and the names of the trees, and considering how it is included in the mid-term test.
Sunday, February 23, 2014
Sunday, February 9, 2014
Week 5
The snowstorm was terrible this week, yet I managed to go to both of the lectures and I am very proud of myself for doing so. In both of the lectures, Professor Heap focused on leading us through the first assignment.
On Monday, he led us through the process of moving cheese and explained basic rules for moving cheeses around. During the lecture, he gave us an example of move_cheeses which prints the intermediate steps of moving a pile of cheeses from a place to another. I think the function is very helpful and gave me basic information about the general rules of moving cheeses. If there are more than 1 cheese, the function uses recursive functions to move cheeses around. I don't think understanding recursive functions is too hard for me. It is not easy, of course, but I can still figure it out after some work.
However, writing recursive functions in the lab was a lot more difficult than I expected. In the first two problems, we were asked to trace codes for greatest common denominator and binary representation. Tracing the codes was fairly simple, and the lab handout helped to specify thing a lot as well. However, I found it a lot harder when it came to me writing the codes myself. At first, I was kind of lost when my TA told me that I am not allowed to use a for loop. But later it got clearer and I was very happy that I could figure things out myself.
On Monday, he led us through the process of moving cheese and explained basic rules for moving cheeses around. During the lecture, he gave us an example of move_cheeses which prints the intermediate steps of moving a pile of cheeses from a place to another. I think the function is very helpful and gave me basic information about the general rules of moving cheeses. If there are more than 1 cheese, the function uses recursive functions to move cheeses around. I don't think understanding recursive functions is too hard for me. It is not easy, of course, but I can still figure it out after some work.
However, writing recursive functions in the lab was a lot more difficult than I expected. In the first two problems, we were asked to trace codes for greatest common denominator and binary representation. Tracing the codes was fairly simple, and the lab handout helped to specify thing a lot as well. However, I found it a lot harder when it came to me writing the codes myself. At first, I was kind of lost when my TA told me that I am not allowed to use a for loop. But later it got clearer and I was very happy that I could figure things out myself.
Monday, February 3, 2014
Week4
In week 4 lectures, we looked at assignment 1 together. And I haven't read through the assignment handout yet, which I will read really soon. During the lecture, we talked about the nesting depth of list with "return (1 + max([nested_depth(x) for x in L] + 0) if is instance(L, list) else 0). This is probably one of my first recursive functions I have ever seen. It is very interesting to see how the recursive function can combine if and else into one or two lines of functions. It first checks whether the given variable is a list or not, and then decide what to do with the function call.We also saw tree_burst.py. The function kept calling itself using recursive codes, and generated literally tree burst which was pretty impressive.
I have found the lab and exercise 2 to be fairly easy to follow and did not take that much time for me to figure things out.
I have found the lab and exercise 2 to be fairly easy to follow and did not take that much time for me to figure things out.
Subscribe to:
Posts (Atom)