Understanding branch and bound algorithm