2015年3月1日星期日

Summary of Recursion

It's the seventh week I take computer science 148, the topic of SLOG today is to summerize about recursion, which we learned in last few weeks. 

Honestly, the first time Prof Diane talked about 'recursion' in class, I thought that it would be so useful if I had known this in csc108. To use the recursion would make the assignments a lot easier.

There is an easy example showed below:
to sum the numbers in [2,[3,4,[2,7,9,[[26, 16],34,67]],34]]

By using for loop or while loop, the code would probably be 10 or more lines long, and it's easy to make mistake on the complex loop.
In contrast, it's extremely easy to write a code in recursion form to solve this question. 

In my own opinion, recursion is like a huge loop which can keep running on each subelement of the given element till the last one. Similar with the mobius strip, the end of one loop in recursive code is the strater of another.

What's more, we were also told how to use recursion in the 'Tree Class', although I'm still not fully understand the 'Tree' structer. Since the recursion in that is quite complex, I believe it's essential to do more exercise and visializer on that.
 

2015年2月22日星期日

148 SLOG #7

Earlier last week we learned about the 'ternary if'. With this mathod, we can combine the 'else if' code into a single line. It can help us to make our code easier to read.
For example:
if temp >= 15:
    outcome = 'Hot'
else:
    outcome 'cold'
can be combine into:
outcome = 'Hot' if temp >= 15 else 'Cold'

Later we were introduced to the Tree function. We learned about the definations of the term Tree such as 'leaf : a node with no child' and 'internal node: a node with one or more children'. These definations are easy to understand after I built a Tree by myself for exercise. In order to use the Tree efficiently, we need to fully understand how 'recursion' works, because we need to use 'recursion' in each subtree. Hence it will be very confusing to deal with a Tree class if we are not used to use recursion.

In the Lab7, we did the exercise about implement the recursive function respect to the Tree class. My partner and I were struggled on the 'implement list_leaves', because both of us were not familiar with using recursive function. We did not finish all the exercises in the Lab, so I believe we need to practise more on these functions at home.

2015年2月9日星期一

Week 3 SLOG

This is the third journal I write about CSC148.

It's a quite busy week, lots of tests and review sessions I need to take. We just finish the mid-term of CSC148 on wednesday. Although it's not that difficult, I'm still worry about some details about docstring and __repr__ typr and so on. The most difficult part of the test I think is the limited time. Normally when we write code for the assignment or practise, we do not have a time limit. Hence after I finished first question of the test, I found I spend too much time on it. So it's quite hurry for me to do the last two questions. To avoid this situition on the final exam, maybe it will be helpful if I force myself to finish the assignment or pranctise in a limited time.

In last week's lecture, we learned about how to use sum and isinstance in python. By using these build in function, the code we need to write become shorter and easier to understand. These method make the code we design clean and logical. As prof Diane saied on the lecture, 'As programmers, our job is to make our code easy and logical, which is a very difficult job.' These build in function can help us to clarify our design. This is also what the 'class' do in python, to make the code easier.

2015年2月1日星期日

Week 4 SLOG

Since last week I wrote about why geeks should write, I will conclude how I feel about this course in the first few weeks.

In the first 4 weeks, the thing we mostly talked about is 'Class'. Although I've already learned about class at the end of CSC108, it's still not that easy for me to understand. The definition of 'self' is what I think the most difficult part to understand. What's more, how to use class to store the message is always confuse me a lot, especially the relation between the memory address of each class. 

On wednesday last week, we finished our first assignment of CSC148, we worked until the last min. Along with working together, I was getting used to use class to store and varify the data. And I also figure out what's the job of '__str__', and '__eq__' in the class. In a sentence, although we spent tons of time in this assignment, I learnd what I would not know if I work with myself.

In these weeks, the bigget achievenment I think I got was that my work is more orgnized that before. By using class, the code I wrote was much more clean than before and easier to read. 

There's also many things I'm not doing will in the first few weeks, for example, Sometimes I'm not able to get up at 8'oclock morning to attend the lecture at 9. To avoid it, I need to sleep earlier at the night before class. More over, I also need to review the lecture slides and codes from the class every day ,so that I can keep the knowledge fresh in my brain.

2015年1月25日星期日

Why Geeks Shoud Write


As a rookie in the computer science region, I write this as my first journal of my geek career. The topic of the journal today is "Why Geeks Should Write". To understand this question, it's necessary to figure out what "geek" means.

"too much information to decode the Matrix. You get used to it. I…I don’t even see the code. All I see is blonde, brunette, red-head." -------- 《Matrix》

Geeks are the people who have great wisdom but appear slow-witted. Geeks are maverick; they enjoy challenging the knowledge they know, and believe that only discover and innovation can make this world better. Geeks would like to make hard things simple, and it's also what they do in their daily life. Althought it sound's similer with "Nerd" ,we should seperate "Nerd" and "Geek" into two opposite regions. Geeks have an ambition to create a better and idealized world, althought maybe it's only possible on the internet. They take internet as their world; they try their best to keep their world pure and strong.

In order to make a better world in internet, geeks will not stop learning and seeking new knowledge. However, procedure, computer and internet are just like a bottomless pit that can never be explored clearly. In comtrast, people have limited brain to store the knowledge. Hence, geeks should keep writing and recording what they learn and find daily or weekly. Writing things down is a way geeks talking to themself in the future, and provide themself a spark in the darkness.


After all I write above, Another reason why geeks should write is that geeks write not only because it make them better, but also because it make others better, make the people who read their artical better, make the internet and even the world better. It's not only about them self, it's about shearing, the most important quality for geeks on internet.