Algorithms and discrete structures