Added 'cost' statistic to all algrothims.