Sorting is a method that change the sequence of a list in the order that we want to. For example, we can sort a list of numbers: [5,2,7,8,4,9,6,3,1] by calling the python build-in method '.sort()' to arrange it in to [1,2,3,4,5,6,7,8,9]. This method also can be applied in a list of letters. However, python build-in methods have some limits. It can only sort particular things that has a certain order. Therefore, we must other methods to finish that. It remains that in CSC108 we have already experienced some methods of sorts such as selection sort, bubble sort and insertion sort. Those sorts have their own way. The way the compare items is different with each other. So there's another problem emerged-- Efficiency. The step of those sort method is different. For example, in merge sort, the idea is to divide the list in half and then merge sort the halves then merge the sorted results. There is two variables, times of splitting the list and the steps that each time we split. Less steps means less time to run it then it is more efficient. To be accurate, let's take look on some data.
This is what we did in this week's lab. It is obvious to see that the different method has different runtime when they have a some list. Form this table, we can tell that the python build-in method sort() is the most efficient method.
Meanwhile, we just compare this table vertically. We also can compare it horizontally. With the increasing of length, the time of all of methods increased. But they increased at different rate.
Some are increasing exponentially. Some are increasing linearly. This is what we learnt the Big O.
It is like the Big O in CSC165. It talks about the runtime at worstcase. g∈O(f) means “g grows no faster than f” (or equivalently, “f is an upper bound for g”).
Sunday, March 30, 2014
Sunday, March 23, 2014
hard assignment2 p2
This week is the due week for assignment 2 part 2. This assignment is really hard. The case is so difficult. At the start, I thought the bar and the dot is the hard case. However, after I study more. The hard case is the star. This week's lab is also hard for me.
Sunday, March 16, 2014
preorder&inorder
This week, we were doing this preorder and inorder for a TreeList. It is very interesting topic. I am very happy that I understand everything during the lecture. The way it works is very attractive and I enjoy those steps. I think this week's lab is quite hard. Compared with lecture, the lab is difficult for me to do. My partner and me cannot finish half of handout. But it is a good practise. Some recursion function and Treelist makes the 2 hour lab interesting.
Sunday, March 9, 2014
linkedlist
This week, we learnt more about linkedlist. It is very new for me and I do not understand too much during the lecture. However, the lab helped me a lot. The exercise let me understand much more about how this linkedlist work, how the ids going, how to add a new thing to 'prepend' to the list. I am very interested in the part of changing value at the index in the list. At the start, i thought that was a list. Then I realise that it is not a list. It is more complex then a list. So the step of changing value becomes hard. I really enjoy this lab exercise. I can ask questions and practice.
Subscribe to:
Posts (Atom)
