This blog I want to talk about the
labs’ experiences and changes through the weeks. As I said before, I felt difficult
in dealing with the problems of labs in beginning weeks. I thought there are
two reasons. The significant problem is that I was not familiar with context. I
did not read the readings and review the slides with codes before the lab. The
other problem is communication because I did not know how to communicate with
the partner. Luckily, these two troubles are all solved through the weeks. I
knew that I should read the readings and review the example codes for
preparing. Also, this habit helps me catch up with the context we learn from
the previous week. In addition, I made a good friend, who is also the partner
with me for working labs’ problem. We can discuss the questions about CSC and
prepare for the tests. All in all, the labs are valuable and I really learn
from them.
Sunday, March 23, 2014
Sunday, March 16, 2014
Assignment Two
For the assignment two, I work with new
people. One of them is really good at coding and I never see someone who has
that clear thought in planning code. The Part one is pretty easy because we
only need to create __init__, __repr__, and __eq__. When we done the analyse,
we done the part one.
Compare to part one, part two is
complicated. However, honestly, it is much easier than assignment one for me.
There are four main functions we need in regex_functions and we write some help
functions. For instance, we test string s symbols and three types of forms separately
in using four help functions. Then, we write in_regex to connect fours. The
other example is writing function permutation to help all_regex_permutation.
These good thoughts are all
come from my excellent partner. I really want to learn from him and do well in
CS.
Sunday, March 9, 2014
Linked Lists
These two weeks focus on linked list, a
recursive date structure, which is consisted of nodes and each node have a
reference to the next.
From the picture below, we can see the
linked list has two parts: head, the first element of the liked list and rest,
another LinkedList that has the same structure. N the class LinkedList, we need
to check whether head or rest is None. If both of heaf and rest are None, the
self is empty. If not, we give the value of head to self.head. Then we assign
the rest is an empty LinkedList if the rest is None; otherwise, we put self.rest
= rest. In addition, method prepend is for adding new item to the front of its
self and ,ethod decapitate is for deleting item from self by using del. The
method __getitem__ clearly shows the recursion. Using ind = ind – 1 to get the
item by going deep into the rest.
The importance of this type list is
collection. For instance, the first node in the list can refer to the whole
list.
Sunday, March 2, 2014
Recursion
This is the second time I write the
blog that is about Recursion. Throughout the continuous learning according to
this topic, I am more familiar with it. Besides knowing what it is, I learn how
to use it now.
A1 gives us the opportunity for
practicing of using recursion. We need to solve the challenging problem by
applying the structure of recursion. Also, it is very helpful to work with
classmates. We can help each other on working it.
In
addition, “Tree” is the good example. Form the structure of Tree, it is really
like a family. There is a root, which is also the original parent and its
children also have their children. In the methods of Tree, all returns are only
one line owing to comprehensive and they clearly show the abstract solution. For
example, count is the method for counting the nodes in the Tree. The function
is “return 1 + sum([count(n) for n in t.children]). It counts all the parents
and leafs. If the n is also the parents, it needs to call the function itself.
Also, we could use the structure of Tree to do the calculation: preorder,
inorder and postorder.
Recursion is very important. The main
benefits are these two: firstly, the program using recursion functions is
obviously clearer, simpler, shorter, and easier to understand. Secondly, it
directly reflects the algorithm. All in all, I prefer recursion to iteration.
Subscribe to:
Posts (Atom)
