Theory Behind Algoritm