Ich geb mal einen Tipp, vielleicht antwortet dann ja jemand darauf:
Es ist ein bekannter Algorithmus