notes on algorithms 582642