2015年2月28日星期六

week 5 - impressions of tracing recursion from week 4

Recursion



We learned recursion. I think to understand recursion, knowing the basic structure of recursion coding is the most important thing.

The general form of recursion is:

         if <condition to detect a base case>:
         <do something without recursion>
         else: # <general case>
         <do something that involves recursive call(s)>

However, it is still not clearly show what recursion is by only understand the general form. In the class our prof provide us example about sorting. Sorting or counting numbers are some simple examples of recursion. 

The sorting of a list of number could be write as:

         def quick_sort(L):
               ‘ ‘ ‘(list) -> list
         if len(L) < 2:
                 return L
         else:
                 return (quick_sort([x for x in L if x < L[0]]) + [L[0]]          + quick_sort([x for x in L if x > L[0]]))

But we have to make sure L is a list or the type it should be in other exercise. 


Recursion is deeply related to binary tree. We can count the height, number of leaves or parity of the tree by using recursion.

2015年2月2日星期一

Week 3: Why Geeks Should Write

How to define geek?

I checked wiki and found out the following definition:


"The word geek is a slang term originally used to describe eccentric or non-mainstream people; in current use, the word typically connotes an expert or enthusiast or a person obsessed with a hobby or intellectual pursuit, with a general pejorative meaning of a "peculiar or otherwise dislikable person, esp[ecially] one who is perceived to be overly intellectual"."

In this course, I believe geek should be defined as people who knows computer and coding. We all think CS students should be good at coding, they know computer, they design internet and even use code to talk to each other. This is true for a professional CS students. But this idea ignores the other side of geeks: geek should write.

Without writing, geek cannot share their believes and new found to public via internet or magazines. If Apple publish a new product ishoes, which has multiple functions with breakthrough technology, the geek who designed it are not good at writing. Assume no one understands how will that breakthrough technology be applied to other things, there will be a waist since that geek cannot tell to the public about his or her technology, which could help may factories but only applied in ishoes.

The above are some superficial thought for me.