Foundations Of Algorithms