Saturday, April 4, 2015

Last Week: Last Impression

   We finally finish the course! During the 4 month study of csc148, I feel like I obtain more confidence of writing codes and implementing functions. Comparing to the basic materials in course csc108, csc148 leads us to an exploration of more complex and complicated concepts such as recursion and linked structures. These concepts are also useful in the further study of computer science. 
   In the first few weeks, we mainly reviewed and in-depth studied class structures. I still remember how I struggled with the implementation of general class for the subtract square game state; but now I feel more confortable construct classes and subclasses after striving those 3 assignments. 
   Recursion impressed me the most among all the materials taught in this course somehow. I was simply fascinated by the idea of using the function itself as a helper function within the body. Though implementing a recursive method was a little challenging at first, the tree classes let me practice more and helped me to master the concept of recursion.
   Linked structure was probably the most difficult one for me. I spent a lot of time trying to understand how the append method of LinkedList work. By drawing diagrams, I found it gives me a clear idea of how to implement that method. 
   The final exam is coming! Hope I can get a satisfying result that will encourage me in my further study of computer science.

Sunday, March 29, 2015

Week 10: Revisit Week 5

   I revisit my week 5 SLOG that I talked about my first impression of recursion, which was not so good; I am glad that now I am comfortable understanding and writing recurssive functions. Like I pointed out before, it is essential to know how to trace a recurssive function before you can write one. And tracing is also a useful method to test whether the function you wrote works correctly.
   After a long period of time working along with recursion, I find that recursion is extremely efficient and can save us a noticable amount of time and lines for the problems that could break into parts. For example, as another SLOGer wrote, 6! could break into 6x5!, and then 6x5x4! and so on until it approaches to 1!; then we can use 1! as our base case recurse all the way until we get 6!. It is an really interesting example that gives me a clear mathematical comprehension of how recursion works.

Sunday, March 22, 2015

Week 9: Prepare for the Test

   We had the second term test in this week. I feel less confident for this test than the last one since I have learned more complicated structure: linked list. According to my last week's SLOG, I find that drawing diagrams for linked list methods is extremely helpful during the test as well.
   For this term test, I managed my time efficiently so I did not rush during the test as the first one. However, I did not feel confident about this test...I must say that the biggest failure is that I did not prepare for the part of definition of Tree(question #1 on the test). I overly relied on the past test so I did not think about such question will be on the test. Luckily, I went through the inorder/preorder/postorder traversal once so I have done the order question right(hopefully).
   Due to the TA's strike, we still do not have a chance to get our tests back to see what we did wrong. Hopefully the strike will be settle soon:)

Saturday, March 14, 2015

Week 8 Linked Structure

    Week 8 is all about linked structure. Unfortunately I was sick on Monday, so I did not have a chance to be introduced to this new topic. When I returned to the Wednesday's class, I was stunned by the concept of linked list and all its methods. The only thing that was understandable was the diagram. It gives me an overall understanding of linked list and how each node in the list relates to each other, and perhaps how it works. 
    Because of the absence of the first lecture of linked list, I spend extra time reading the course note and slides. I find the most helpful way to understand and solidify the linked structure is the lab, though due to the strike the lab was cancelled. By following those codes, I can gain better comprehension of those methods including the ones that once stunned my during the lecture. I also find that drawing diagram is extremely helpful to both comprehension and implementation of the code. Here is one of the diagrams I drew to for the append method:


Drawing graph gives me a visual understanding of how the method work; sometimes it also gives me hints to solve similar problems as well. 



Wednesday, March 4, 2015

Week 7: A Challenging BTNode Method

   In week 7, there are more about recursive methods and the Tree class. The contents of lectures are clear and easy to understand. However, for the first time I feel the lab exercise is challenging. Both my lab partner and I struggled to implement the method list_longest_path(node). This method supposes to return a list of the data of a longest path of the node. We started with an if statement that indicates the base case:

    if node is None:
        return []

Then we also found cases that do not need recursions, which is the Tree only contains one leaf(the length of the path is 1):

    elif is_leaf(node):
        return [node.data]

So far we were confident and clear. However, what we did not notice is that, besides the case above, there are two more cases that we could implement directly without recursions(the length of the path is 2); and these codes are very important for the recursion to work:

    elif node.right is None:
        return [node.data, node.left.data]
    elif node.left is None:
        return [node.data, node.right.data]

With these codes that construct a loop for the recursion to work, we finally successfully implemented list_longest_path(node) method:

     else:
        left = list_longest_path(node.left)
        right = list_longest_path(node.right)
        return [node.data] + left if len(left) > len(right) else         [node.data] + right 

   The main problem we encountered was that we always forgot to contain the node.data of the parent tree in the list. We also had a hard time figuring out how to make the program choose the longer path amoung node.left and node.right.
   There might be tuns of similar problems that I will encounter in the furture, but the ideas of implementation are the same. Therefore, understanding the essentials of implmenting recursive methods will be extremely helpful for me in my furture programming experience.


Sunday, March 1, 2015

Recursion

   Recursion is a tricky but really fun part for me in the study of computer science so far. I am fascinated by the idea of repeating itself within itself, though this idea is also a little complicated to understand and apply. Recursion is very convinient in programming since it simplifies and divides the problems into parts and solves them part by part. It saves lots of unecessary codes and is able to solve extremely complicated problems by several simple codes.
   During the lectures we learn and understand recursion by tracing it, from the simplest base cases to the more complicated ones. The first recursive method we encountered is sum_list. We first take a look at an extremely easy example call such as sum_list(27), which the argument is an int rather than a list. So that we can simply figure out the condition for recursion. Then we can clearly see how it works for a list, such as sum_list([1, 2]) and a nested list, such as sum_list([1, [2, 3]]), and so on.
   With the understanding of recursive methods, now we are able to implement them and apply them! Though the first implementation of a recursive method takes me about an hour to solve it, applying recursion to some methods will become easier after some practice. In last week's lecture, we've tried to implement BYNode.evaluate() method using recursion. I find that it is easier to solve the problem by thinking about the base case. After solving the base case, consider a typical example that needs the idea of recursion.(Agreed by another SLOGer) This is the most difficult part since it is the main part of the function that requires lots of thinking and deep understanding of the method. When both 2 parts are done, we can write them in the 'if...else' form.(We can also check whether the code is correct by tracing them.)

Friday, February 27, 2015

Object-Oriented Programming

   As a beginner of studying computer science, such terminology actually scares me when I first read it, because it sounds like a really complicated programming type that would take me a long time to understand it. In course csc148, I have learned a lot about classes, inheritances, and recursions, which give me the first impression of OOP concepts.
   Inheritance is a main idea of object-oriented programming. Since in programming, it is very common to use one part of a code in order to develop more complicated and specific functions. Instead of just copy and paste the codes, using the concept of inheritance would be helpful and convinience. It prevents errors that might occur efficiently while modifying the original code.
   In implementation of classes, the general class would be the code that we needed for further use. The methods of a general class should be general as well in order to be applyed to more specific occasions. However, many methods in general class can not be used directly to perform a job; they need to be inherited in sub classes so that they can be called. Sub classes are the classes that inherit all the methods in its parent class(the general class) and perform specific functions. For example, in assignment1, the gamestate class is a general class that will work for many specific games; and the subtractsquare is a subclass that covers all the functions its parent class has and actually performs them.

Friday, February 6, 2015

Week 5

   In these 2 weeks, I have learned about recursions. The first impression of recursion is not so positive as I am scared by the concept of using the function itself within the implementation of that function, which seems complicated. But as the professor shows us the whole method of how to trace recursion, it becomes more clear and straight forward to me. Recursion is somehow like a loop; it can give us the result of each simplest element within the nested list directly, and then break the nests while using that method directly. Thus, tracing recursions will be easy as long as I understand the body of the function.
   However, in week4's lab, there is a part that requires us to write the body of the function based on the examples using recursions. I spend about half of an hour to work that out. Now I understand that writing a recursion function is way more difficult than just tracing it. Hopefully I can find a way to solve this problem in the next lectures.

Friday, January 30, 2015

Week 4

   After about a month of studying csc148, I find that this course is like a combination of csc165 and csc108. So far I have learned more about classes, and obtain the ability of implementing a classes and its subclasses. Since I have learned about class in csc108, I feel like it is an easy part for me in the beginning.  
   However, when I tackle with the assignment1, I feel confused about which method should be used in which class. I can create all the subclasses and write all the methods for that class, but there was a hard time for me to build the general classes, especially when I build the gameview class. Luckily, my group members solve this problem and explain it to me carefully -- Since general classes should work for all kinds of games, so when designing the general class, in this case a general class works for subtract square, just think of that the method I am going to design will work for other games such as chess. Then some methods such as legal_moves will not only apply for subtract square but also chess. Therefore, the arguement needed will not just be numbers, and I should raise the 'NotImplementedError' for that. Finally, I understand that how 'general' my class will be and how the method in that class will be designed.

Sunday, January 25, 2015

Why Geeks Should Write

   Writing is an essential skill that give us the ability to express our opinions and believes through words and letters. Journalists write to report the news that tells people about the whole event; Authors write stories that let people experience and enjoy the astonishing plot; Scientists also write reports and papers to explain their ideas and support their theories. For computer scientists, writing is also important and necessary.
   Similar as all the other scientists, computer scientists also need the ability to write reports and papers that explain their work or codes. Since a large portion of our work are done in python or other computer languages, which are difficult for other people to understand, we have to write descriptions or explanations in order to make our original work easier for other people.
   As another blogger pointed out that writing is essential for documentation, which is also an important reason for us computer scientists to improve the ability to write.
   In addition, though computer scientists work with computer languages for most of the time, we still use normal languages and live normal lives like others. Writing can  improve our ability to observe the world. Through writing, we observe the object or the incident more carefully and meticulous, so we are able to gain better understanding of what we have written. Moreover, good writings reflect good education. As we write more and more, we learn more complicated and sophisticated words and sentences. At the same time, numerous abilities are developed and improved, such as critical thinking.
   The benefits of writing are countless. Therefore, all kinds of people, include computer scientists, should improve their ability to write.