Added KMP prefix function building algorithm