my exercise on introduction to algorithm