Sunday, April 5, 2015

Week12:last slog



This is the last week, which means that I am writing my last slog of this course. Probably I will keep my slog next term. This week, I will write my impressions on week12 and look back over the entire course.

We continued on talking about efficiency. Here is the definition of big-o. 

When compute the running time of sequences and loops, all we need to do is to count the line step by step. However, when it comes to conditions, we are supposed to find the running time of all cases and pick the worst case. Finally, I learned about abstraction (binary tree and list comprehension are abstraction).

I’m so surprised that now is the end of the course. Throughout CSC148, I covered a variety of new concepts and faced tough challenges. Especially in assignment 2, some solutions are hard to figure out. Luckily, I was able to discuss with my partner and turn to TA. Here I would like to sincere thank them for helping me and being with me.

In April, I will concentrate on preparing final and reviewing all the materials in this course. Good luck for everyone!!!!!

Monday, March 30, 2015

Week11: revisit my previous slogs



This is the last but one week of this term. It is time to look back to my previous work and draw a conclusion. After visiting my slogs from week3 to week10, I got really amazed that I have learned so much in this course such that class, stack, tree, recursion and so on. All of these topics are based on what we learned in CSC108. However in this course we need to think more and attempt to make the code more efficient.

Here I would like to talk more about my slog of week7----recursion in trees (click here to visit). As is known to all, recursion is one of most important topics in this course. In week 7, we had got in touch with this magic recursion just for several days. I can still feel the stress I came across at that time. Some basic methods like height were done at the very beginning. What I agree with is the general method I conclude to implement recursive functions. Now that I get adequate exercises, I have a deeper understanding of recursion----“think lazy”. Let the function do most of work. Additionally, visiting my earlier posts provides me with an interesting way to reflect on myself.

What’s more, I visit some of my classmates’ slog to compare their feelings with mine. What I subscribe to is Justin Song’s view on advantages of revisiting our slogs, which merits attention. I also share the same feelings with Nadine about recursive functions. Additionally, I want to address that visiting other’s slog is a good way to communicate with classmates as well.

I also want to talk more about the materials this week. We covered the topic of efficiency of functions this week(Big-O). Do you think it sounds familiar? Yes, this is taught in CSC165 as well. However, what is different is that we focus on calculating the time of the worst case in CSC148. I think calculating the worst case’s time aims to make the code more efficient.

Tuesday, March 24, 2015

Week10: impressions of this week



In this week’s lecture, we looked back at our a2 and learned the assertion in unittest. In a2, I have learned how to deep copy a list. One of the advantages of deep–copy is that it can avoid the original list's being mutated, which may cause ugly circumstances. For example, we need to find several possible game states based on the original one. Once we get one possible game state with the original one being mutated, we can never find other possibilities using the right game state. In this case, deep-copy helps a lot. There is an easy example:
L1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
L3 = [[item for item in r] for r in L1]
Now we check the id of both L1 and L3. They have different id addresses in spite of the fact that they have the same elements. Sadly, I was unable to figure out the way to deep copy when doing a2. So this approach gives me a new idea about how to think and solve the problem. To practice it, I apply this deep copy in my a2 and this solves many problems that I couldn’t figure out at that time.

Another new thing I learned this week is assertion. We covered this stuff in testing minimax.
It is written in the form of this:
 assert <condition> , <error_string>
---> if not condition: raise AssertionError(error_string)
From slides, assertion can be used to state two things:
•what we know is true (assuming our reasoning is correct) at a crucial point in the code.
•what we assume is true at the start of a function or method
Since I haven’t got enough exercise about unittest before, I feel confused about assertion. So I reviewed the slides and worksheet after class. This helps me to some extent to get a clearer understanding of assertion. But I think knowledge about test still confuses me. I hope I can practice it more in the next week.

Sunday, March 15, 2015

Week 9: impressions of week 8 and week 9



We have our second term test on Wednesday this week and continue on the topic of binary tree. On Monday’s class, we implement some functions that mutate BSTs such as insert and delete. Again, this is all about recursion. Experiencing several weeks of practice, I have made progress in implementing recursive functions. Compared with recursion I learned in last several weeks, recursion mutating BST can rely on some specific attributes of BSTs, say, BST’s left child is always smaller than its data and the right child is larger than its data. Take insert function as an example. Here is the code: 

               def insert(node, data):
                  ‘’’(BTNode, object) -> BTNode’’’
                  return_node = need
                  if not node: 
                      return_node = BTNode(data) 
                  elif data < node.data:
                      node.left = insert(node.left, data)
                 elif data > node.data:
                      node.right = insert(node.right, data)
                 else:
                      pass

If node is none, then create a leaf. If data is smaller than node.data, we insert in node.left .  Or vice versa. We don’t need to look at the whole tree. Instead, we focus on the part that meets the requirement. And that’s why BST is more efficient.

Due to the strike, we don’t have labs this week. So I finish the task by myself. From this lab, what I learned is to draw pictures when write some recursive functions. This may seem to be useless when solving some easy problems. But when we encounter some trickier questions, it is a significant approach to the final solution as well as a good way to think about the tough questions in the correct direction.

Wednesday’s test is not very hard for me. To prepare the test, I review the slides and codes the prof uses in lecture, as what I did for test one. What’s more, I redo the labs, which is helpful as well. Also I revisit my former slogs to comb through the material I learned before. I have to say it is really helpful. Slogs reminds me of my feelings and questions about that week’s learning. As a result, I can concentrate on knowledge that I am weak in.