Welcome, this is Dr. Cu.

Lonely in the Dessert.

About Sorting

For small arrays, the next three classic sorting algorithm suffice.

Selection Sort

The complexity does not depend on the initial placement of the data. It's quite appropriate only for small n as O(n^2) grows rapidly. In contrast of a O(n^2) comparisons, it requires only O(n) data moves. Thus, selection sort could be a good choice over other counterparts when data moves are costly but comparisons are not.

Bubble Sort

 The number of loops depends on the initial placement of the data, which means the sorting will be terminated when no exchages are done during one pass.

Insertion Sort

The insertion sort algorithm is O(n^2) in the worst case. For small arrays, the simplicity makes it an appropriate choice. For large arrays, insertion sort can be prohibitively inefficient unless the array is already sorted, in which case, the sort is O(n).

For extremely large arrays, faster sorting algorithms are needed.

Merge Sort

As one of the two most important devide-and-conquer sorting algorithm, merge sort works in elegant recursive manners. Besides, it’s also readily extended to external sorting. Oblivious to initial placement of data, merge sort always gives the same performance. The complexity is O(nlogn), which is significantly faster than O(n^2). Despite extremely efficient with respect to time, the merge sort requires an auxiliary array. This extra storage and the necessary copying are disadvantages.

Quick Sort

Similar to Merge Sort, Quick Sort performs better when the array can be halved for each round. Thus, the complexity is O(nlog(n)), which is the best case. For the worst case, the complexity is O(n^2). The average behaviour of Quick Sort is O(nlog(n)) as well. We have shown that the  Merge Sort  is alwasy O(nlog(n)), the  Quick Sort is faster in practice and doesn’t require an auxillary array for merging.

If the data is sufficiently “random”, Quick Sort performs no worse than any known comparison-based sorting algorithms. While the worst-case behaviour of Merge Sort is of the same order of magnitude as a quick sort’s average-case behaviour, in most situations Quick Sort will run definitely faster than Merge Sort. However, the Quick Sort is significantly slower than the Merge Sort for worst case.

About Thread-safe in Java

If all the following rules are obeyed, the class is known to be thread-safe.

All fully synchonized class is a class that meets all of these conditions:

  • All fields are always initialized to a consistent state in every constructor.
  • There are no public fields.
  • Object instances are guaranteed to be consistent after returning from any non private method (assuming the state was consistent when the method was called)
  • All the methods provably terminate in bounded time.
  • All methods are synchronized.
  • There is no calling of another instance’s methods while in an inconsistent state.
  • there is no calling of any non-private method while in an inconsistent state.

Hiking Under the Beautiful Sunshine

It’s a beautiful day with great sunshines. As usual, we went outside. This weekend, we went to the Peak, nearest to our home. Some photos can be seen here.

Leaf sleeping in the sunLeaf sleeping in the sun

My First Step to the No-return Journey of Photography

Okey…this is gonna be my first shooting with my new 5d mark iii, also my first step to the no-return journey of photography. I want to thank all my friends patiently giving me precious advices on lenses choices. Finally, I gave up the in-kit 24-105mm and grabbed the bloody expensive lenses, 24-70mm f2.8 ii. By bloody, I mean abso-fucking-lutely bloody hell expensive for a green hand like me.

I can see I will definitely keep my retina Macbook Pro non-upgraded for a long time, until the TRUE next generation Mac with a brand new design.

Why don’t you have a look at my virgin shot to my billingham bag, which is also bloody ~~~ (omitted…). Yes, I know it’s a fantastic shot, and won’t allow you to comment.

My first step to the no-return journeyMy first step to the no-return journey

Though very tired today, my wife became the first model before my camera tonight. Pictures were taken around Saiwan, where we live. The album is here.

More fantastic photos are comming, stay tuned…

Nanjing Trip Day 1















大潭郊野公园 + 港岛径五段


大潭郊野公园入口大潭郊野公园入口 英式拱桥远眺湖景1英式拱桥远眺湖景1

英式拱桥远眺湖景2英式拱桥远眺湖景2 英式拱桥远眺湖景3英式拱桥远眺湖景3


大潭笃水库大潭笃水库 水坝水坝

水坝上游水坝上游 标准动作之一标准动作之一

标准动作之二标准动作之二 看咱们pose摆的看咱们pose摆的



被暴雨欺负了10分钟被暴雨欺负了10分钟 湿透了湿透了 爬山如人生,高峰之后难免低谷爬山如人生,高峰之后难免低谷

真心湿透了真心湿透了 站在乌云之巅落汤鸡站在乌云之巅落汤鸡

为家花遮雨湿身为家花遮雨湿身 遥望红山半岛和来时的路遥望红山半岛和来时的路

从这个角度俯瞰维港和中环从这个角度俯瞰维港和中环 标准动作之三标准动作之三


到了五段的终点,我们沿着quarry bay的小路直通文明世界。这段小路大概3km,全程下坡,无聊的很,可以边走边睡觉。

Omega Planet Ocean Night

movie: planet oceanmovie: planet ocean

Invited by Omega, my wife and I have a lovely chance to attend a cocktail party at IFC tonight. I should say the party is organized pretty well, a handsome and nice guy showed us around during the party and we chatted well. The cocktail tastes good, and the color echos the theme well, i.e., beautiful blue, just like the ocean.

cocktail in ocean colorcocktail in ocean color

“Planet Ocean” is a great movie produced in 2011, but the idea of “save the species, save the ocean” needs more supports from each of us. Some guys ask me why I put “lonely on the great wall” on my blog. It dates back to several years ago when I rode my bike everywhere. Sometimes, we went to the Great Wall (yes, the one in China) to collect garbages. We felt sad, because we saw people continously throwing the garbage even we were collecting them. At those sad moments, we felt so lonely.

Love the ocean, love the nature, not merely should we get to action, we should also teach our next generations.

Mr. Dahua Ren (任达华) also came, he kept fit at his age, i.e., 60. Mr. Dahua RenMr. Dahua Ren 瞅给美的瞅给美的

The party is not big, but organized neatly. the lovely cocktail partythe lovely cocktail party

Next, showtime of us couple. We even pretended to be “vampire” celebrities…

vampire couple...vampire couple… the lovely ticketsthe lovely tickets

Hello World

Migrated from wordpress to octopress now. It’s just amazing.

With such a geeky blogging framework, you can just compose your blogs in a coding style. Static web pages are generated locally by the underlying Jekyll, free from server-side craps. Anyway, you are writing plain simple blogs, aren’t you? Besides, version control can be easily handled by Git , coz even octopress itself is released/updated by Git .

What I love most is the superior deployment solution. You can choose to deploy the pages to Github page but I prefer to sync the site to my personal home page using “rsync”. If you are like me, you should be careful at the configuration on “rsync_delete” option of the Rakefile . You should know it well if you are familiar with the linux tool “rsync”. Otherwise, it may screw up all your public_html , and make you suffer from “蛋疼” badly.

Greeting in a programmer styleSource Article
#include <iostream>

int main ()
  std::cout << "Hello World" << std::endl;
  return 0;

Need more time to pull all my previous posts here. But I doubt whether I have to do that.

Cheers && enjoy octopress.