Regular training - Karps algorithm