Add segment tree implementation