Added algorithm from AI book