Programming exercise for Coursera online Stanford Algorithms: Design and Analysis