Tuesday 1 April 2014

WEEK 11: SORTING AND EFFICIENCY

In my opinion, sorting just is an algorithm that puts items in a specified order. We saw a lot of sorting examples in lecture, such as quick, select and merge. And these sorting example can used in different place. I think sorting is very useful because sometimes the sources is very mix up and sorting can help us to sort the sources in order to manage these sources. Efficiency is kind of the run-time about the algorithm, different sorting will have different efficiency. Actually, there is always a question confused me, which is:
def merge_sort(L):
    """Produce copy of L in non-decreasing order

    >>> merge_sort([1, 5, 3, 4, 2])
    [1, 2, 3, 4, 5]
    >>> L = list(range(20))
    >>> shuffle(L)
    >>> merge_sort(L) == list(range(20))
    True
    """
    if len(L) < 2 :
        return L[:]
    else :
        return merge(merge_sort(L[:len(L)//2]), merge_sort(L[len(L)//2:]))

I always don't know how merge_sort works and in what situation we should use merge_sort in order to get the beet efficiency.


Wednesday 5 March 2014

Week 7 Tree

This week I learned about Tree. I realized that Tree is a totally new way to store documents. It is not like list, dict or tuple. However, there is not doubt that Tree is hard and not easy to understand. For example, it is hard for me to understand that what is the relationship between value and children at the very beginning. I always confused that what is children and what should be inside in children. However, I start to understand after I finished some labs and some part of assignment 2. I start to realized that Tree is a very useful tool to help us to store the element. Another thing that confused me is that the postorder, inorder and preorder. Yes, I know what is the different between them, but i don't know why these 3 orders are useful? Anyways, there are still a lot of things that i need to learn about Tree in python. I hope I can finished A2 soon~

Sunday 9 February 2014

Week 4 Recursion and A1

  This week I learned Recursion. I think this is very useful in the further programming.  I actually felt very interesting when I first time contact it at the monday lecture, because I think this is totally new way to think how to programming. It helps me to solve a lot of problems that I met before and I have no idea to solve it without recursion. However, it is not a easy thing to figure out a good and correct recursion function, because you must have a very strong logical thinking. But, It is hard to tell how exciting and satisfying is when you figure out, I think that is the interesting part about Computer Science. 
  However, the thing that really confused me is A1, It used a lot of class and recursion. Sometime i just don't understand what the handout let us to do. For example, I was so confused about step 5 in A1, I don't know what tour.py is for and why it is related to time. Anyways, I will try my best to finish A1. By the way, I very enjoy A1 and the everything that I learned from lecture.

Thursday 23 January 2014

Week 3 Object-Oriented Programming

from my understanding and point of view, Object-Oriented Programming is class. Creating a class is like giving a object some properties that defining by yourself. But there are still some questions in my head. First, i don't understand what __init__ for. Is it the basic properties of that class? Is it possible for a class without __init__?  But, the tutorial work is ok for me, I can finish them very easy. Beside, I still have a question. How can we know this way is faster than that way? For example, is pop() faster or del() faster? I always think how can we know which way is the fastest way for programming. Lastly, I very enjoy the lecture and tutorial work, because they are interesting and fun.