Alorithms 1 for class 2