Naimi-Trehel's log(n) Algorithm