Prediction by Partial Matching algorithm implementation