Apostolico–Giancarlo algorithm