what is the algorithm in this problem..

Printable View