In segment trees , we divide the array into 2 halves and carry it on recursively. Why can’t they be divided into,,let’s day , 3 halves, representing 3 segments. Why is it a binary tree?
Asked
Active
Viewed 61 times
1 Answers
0
Well, You can ask the same question about binary search or any binary decision based data structure like a binary search tree. There are two main reasons for this.
- The implementation becomes ugly, with multiple if else conditions.
- It doesn't actually improve the asymptotic time complexity (time complexity is still O(logn))
You might think that breaking an array into 3 parts instead of 2 might get you a speed up, but this not true. Since if you break an array into 3 parts each one third of the original size, then you might in the worst case recurse on 2/3rds size of the orignal array always, there by making the running time worst than binary search.

Vihari Vemuri
- 56
- 2