Some basic algorithms from CLRS