Davise-Putnami algoritm