theory and design of algorithms 6859239