add segment tree implementation (returns index version)