Wednesday, September 15, 2010

程序员具有的能力

一个程序员要具有哪些能力呢?
抽象问题的能力,把实际问题,抽象为计算机语言;
编写程序的能力,Java和C#确实很好用,却也阻碍了许多程序员;
设计能力,你写的接口应当用得很舒服,架构便于维护和重用;
想象能力,面对一个问题,你想到了哪些解?
学习能力,学习是一个程序员增长价值的核心能力;
数学运用能力,不得不说,计算机和数学真的很近;
不能怕麻烦,大师曾说,如果理解不了指针,那就更理解不了不动点理论。

不怕学了没用,就怕用了没学

请问,什么是技术能力?
技术不是数学,知道了结果的存在性之后就可以呼呼大睡了。
技术不是民工,干一天,领一天的工资回家。
技术是形神一致,知行合一。
不仅仅知其然,还要知其所以然;不仅仅会重复,还要会创新;不仅仅要学在脑子里,还要学到手上。
认为熟练度不重要,注定只是学校里的学生。

踏实地学些东西,不浮躁。

Saturday, September 4, 2010

A solution to problem 13.2-5 of 'introduction to algorithms' (clrs)

If a binary tree T1 can be right-rotated to another binary tree T2, then the count of rotations needed is O(n^2) where n is the count of nodes of the tree T1.
Solution:
It is obvious that if a node is in the right subtree, then it can never be in the left subtree by right-rotations.
There's a corresponding right-rotation for each left-edge. It can not be right-rotated if the left-edge is right-rotated once.
Therefore, if we fix the root of the tree, then there's O(n) left-edges, so there's O(n) possible right-rotations.
There're n possible roots. If the root is fixed, then the elements in the left and right subtrees are fixed.
Thus the total right-rotations between two possible trees T1 and T2 is n times O(n), which is O(n^2).

How did e rise in history?

e is a mathematical constant. But how did e rise?
Morden bankers use complex interest on credit. Suppose the yearly interest rate is r, after one year, the lenders must pay (1+r) dollars for each dollar. However, the banker can use a monthly interest of r/12, and x years equal to 12x months. So the payment is now (1+r/12)^12. Moreover, the banker can use shorter interval for interest time unit.
The universal expression is now (1+r/n)^n -> e^r when n grows to infinity. That's how e rised.

Friday, September 3, 2010

An interesting probability problem

Assume a particle moves forward with a step length i.i.d drawn from a uniform distribution on the interval (0, 1). Show the expected count of steps needed to escape from (0, 1).
Suppose at the nth step, the particle is Yn from its original position. And S steps is needed to escape from (0, 1). Then
E[S] = Pr[S>=1] + Pr[S>=2]+... = Pr[Y0<1]+Pr[Y1<1]+...=1+1/1!+1/2!+...=e
Aha! The expectation of the steps needed to escape from (0, 1) with a step length drawn i.i.d uniformly from (0, 1) is just e! The base of natural logarithm.

Thursday, September 2, 2010

What are papers?

It seems that the problem 'what are papers' is obvious. I have to say no. I am an engineer, not a researcher. I am always looking for ideas to compliment a product. Papers are usually what I must refer to find an proper idea.
Papers can be categorized into 4 types:
1. Setup a new theory. This kind of paper are rare, but make a big step in theory is always the most important. Nothing is more practical than a good theory.
2. Setup a new framework. A very large step in engineering.
3. Setup a new approach. An approach is a method to make a reasonable solution to a problem.
4. Small ideas. Sometimes useful, but a waste of time and paper mostly.
Before you have got a systematic knowledge basis, refer to papers is always a good idea. But it's important to pay more attention to solve problems using your own knowledge system. No need to refer to papers when you already have a good enough solution. Don't abuse papers.