Implementing three algorithms