Monday, March 31, 2014

sorting and efficiency

We have almost already finished this semester.  finally~~. Today, we get the term test two, and so bad ... from assignment, and term test, I found that I have weakness in recursion because I need to revise my code for several times to make correctness. For these two or three weeks, we are studying for sorting and efficiency. Now I will report these two stuffs respectively.

For efficiency,  we use it to calculate the steps and will always want to find a way to do something doing the least amount of work. In this class, it is called 'run time' by calculating time (end time - start time). Usually, we use big-Oh, which  is a rough estimation on the upper bound of the runtime of an algorithm. Big-Oh are always used to calculate steps in the worst case. For example, if an algorithm has (2n^2 + 2n) steps, it will be less than 4n^2. In this case, it get O(n^2).

For sorting, we have learned about select sort, quick, merge sorting. We pick one of these sorting methods by their efficiency, which spends less time when it runs for one circle.Sorting is arranging a list to make the order for unordered list. For example, selection sort in worst case has [n(n+1)]/2 steps, and we can get O(n^2) in efficiency.

In efficiency and sorting, we want to get the most efficient method, which spends the least time to do function.

Thursday, March 20, 2014

week 10

In this week, we are learning sort such as selection sort and quick sort, merge sort, which is about sorting from smallest to biggest to calculate the time. From this week, I find it is useful and difficult for me to handle these kinds of question immediately. I will exercise several problems by myself.

In addition, we finished Assignment two part two!Cheers! In this assignment, we have to write several helper functions for each def. And I use recursion specially for special Tree like Dot, Bar, Star, and Leaf. Through this assignment, I found I am still confused about recursion. For example, I did recursion, and there are a lot of errors, and I have to revise it for a lot of times to finish it. I have a lot of work to do. But finally, we have done this assignment!

In tutorial this week, the work combines binary tree and linkedlist. At first, I was confused about the difference between these two things. Through looking through the handout, I understood them. To do questions, we had to think how to do this and have a good structure. Even though, we have not finished this lab, we get a lot of progress from that.

Thursday, March 13, 2014

week 9

In this week, we are learning about Tree such as Binary Search Tree, which has left and right children, that can be none. In that case, if we want to insert one object, which is bigger than another object, it will be right of another object. In addition, to get preorder and inorder, we should use recursion to get preorder and inorder of left and right children.

In addition, 
I did not finish my lab this week because I am still confused about recursion, and I cannot do recursion successfully at once, I need revise it again and again. The first problem is that I did not discuss question in different situations, for example, to insert something in different BST cases, I use recursion, and wanted to finish it by one case, and got errors. Secondly, I did not understand how it works that makes me confused how to do it.

From these experiments, I need to continue to do lots of exercise of recursion of Trees,  to know how it works.

Thursday, March 6, 2014

week 8

In this week, we are learning about Tree such as BinaryTree, which has left and right children, that can be none, and LinkedList, which is similar as Tree in format. The differences between Tree and LinkedList are in picture, insert and del. To insert other thing into LinkedList, replace it to its value, and the rest is in its children. To do some work, we still need recursion like preorder, inorder, and postorder.

In addition, I am still confused about recursion, and I cannot do recursion successfully at once, I need revise it again and again. And I did not finish my lab this week. The first problem is that I did not discuss question in different situations, for example, In LinkedList, to calculate its length when its rest is None, and is not None. But when I did this, I use recursion, and wanted to finish it by one case, and got errors. Secondly, I did not understand how it works that makes me confused how to do it.

From these experiments, I need to continue to do lots of exercise of recursion, and tree, Linkedlist to know how it works.

Monday, February 17, 2014

Week 7: recursion

Recursion is a Python function that may use itself in its definition. In summary, it divides the whole problem into several pieces of small sub problems. Usually, recursion function involves in calling itself. Firstly, it should have its base case, which is not recursion function. And then, a recursive function should change its state, and move into its base case. If people want to reuse the function, they can use recursion.

In class, we study the recursion through nested lists, which is finding the maximum number in lists of list, turtle recursion about color, direction, and distance in last two weeks. In addition, in this week, we are studying about binary tree about preorder, inorder, and so on.

When I started to study recursion, I found it is difficult for me to solve the problem, and I cannot know how to start. We should cut the question into several pieces, and try them step by step. And now, through exercise from lecture, I try my best to solve this kind of problem, and make a little  progress. I think that if I find the one method how to solve it, and it solve almost questions about recursion.

Wednesday, February 12, 2014

week 6

From this week, we are also studying the recursion about the binary tree which includes some lists, and some list of list. The main part of  tree is  three elements, whose first is object, root of tree, second and third parts are tree lists. In the course, we study some function about the tree to spread the list of list to get the object by recursion. the challenging part I feel is that I have no idea how to start when I read the question firstly. According to the instructor`s lecture, a formula to apply these questions is that [statement if else one statement ]other statement. After applying this formular, I feel confident to solve this kind of question.

In the tutorial of this week, the material is about the dot product about zip and recursion, and tester function. Firstly it confused me what the zip is, and second part is tester function which is how to write the unittest. From the slide, I learn that zip is first element of first list, and relevant in second, and so on. Secondly, importing unittest tester is important to study. From this tutorial, it is a kind of not difficult for us to do, compared with the last several times.
Recursion is to solve the questio with list of list to get the element in it.




Wednesday, February 5, 2014

Week5

This week, we are studying about some recursion about move of cheese in the assignment 1, and a little about local, non-local, global scope, which are new and hard to understand in a short time. 

During this lecture, I realized that I do not have enough efficient way to study 148. After I read the blog from Ziwei Fan`s slog, I found every-week reading is important for me to understand relative stuff about lecture. Today, after I read the week 3 reading, I know a lot of information about recursion, and test function.

Information about recursion, and test function is helpful for labs in week 4, and week 5. In this week lab(week 5), a lot of work about recursion, list of list, we should use [statement if condition else other statement] to solve that problem. But in that time, I just have no idea about solution of that case, and understand only stuff taught in class.