Karn S Algorithm