Thursday, April 2, 2015

Week12 slog

This is the last week of the term. Look back to my term, I think I really did a good job in this lesson, surprisingly.(because I thought I will never pass the exam) And also realize that I still need to pay much more attention to computer science because this is just like a whole, mystery word for me.

Week11 slog

In the previous week, I learnt a lot of new concepts. The hardest one is always about recursion. In a3, we are asked to use recursion to write functions, however, I stuck on those functions for a long time. I think this is because of my insufficient understanding about recursion. I must review the relevant material more.

Week10 slog

In week 9, we learnt to write unittest and also the way of writing minimax strategy.
In a2, I stuck on minimax for a long time because I haven't understand it clearly.

Week9 slog

In week8, we had a kind of revision in Bst. Here is a new function.
def insert(node, data):
’’’ (BTNode, object) -> BTNode
Insert data starting at node, and return root.
’’’
return_node = node
if not node:
return_node = BTNode(data)
elif data < node.data:
node.left = insert(node.left, data)
elif data > node.data:
node.right = insert(node.right, data)
else: # nothing to do
pass
return return_node
In fact, this function took me a lot of time to understand.

Week8 slog

This week, we learnt a quite interesting ting called linked list. In this list, except the back one, everything in the list is pointing the next one and it is also able to delete one thing in the list, just by making the front thing's next equal to the thing's next.

Saturday, February 28, 2015

Week 7 Recursion

  Until now, I learnt a lot on using recursion and put it into actual example. The recursion helps to get deepest in a bunch of abstract, complex data, and to make the outcome simpler. Actually, recursion is a function which call itself for a couple of time when run it.
  To use it correctly, there must exist a very clear way to end the recursion or it would just call itself again and again and will never end. For example, this function:
def nested_concat(L):
’’’(list or str) -> str
Return L if it’s a str, if L is a (possibly-nested) str return
concatenation of str elements of L and (possibly-nested) sublists of L.
Assume: Elements of L are either str or lists with elements that
satisfy this same assumption.
’’’
if isinstance(L, str):
return L
else: 
return ’’.join([nested_concat(x) for x in L])

  In this function, the return L is a example of clear way to end the recursion. Once the list of str, list of str, list of str have been all run, it will simply return the string to end the recursion.
  However, recursion may be quite time-consuming if dealing with a huge data. This may cause the stack over-loading the data. To change this, I must learn more in python.

Sunday, February 15, 2015

week6 slog

This week, I learned how to put recursion to an actual example, a class called Tree. This enables me to look up all the leaves and nodes quickly.

Monday, February 9, 2015

Week5 slog

Last week, I learned recursive function. This is quite interesting because it actually let us avoid lots of repeated loops.

Saturday, January 31, 2015

slog week4

The first week I learned a lot about class thing, rather than in 108. I knew lots of new things in class and how to use them.

Wednesday, January 21, 2015

Why geeks should write

  If a programmer handled a problem lone time ago, time may make he or her hard to remember how they did that at that time, thus he or her recorded what was done at that time for checking later. Also, programmers are actually rearranging their way to handle the problem they have encountered, this helps them to be more familiar with that program as it can be quite hard to understand only in mind.
  Furthermore, the record of a programmer may help a lot for those people who try to learn programming at the first time. If they face the same problem as a programmer used to, the blog would be quite helpful. To programmers who wrote blogs, maybe it takes a few hours to find a way to handle a certain problem, but the things they shared may helps lots of noob programmers save the time to find a way by themselves.
  So, to conclude, writing blogs is helpful for both the programmers themselves and other people.