I am trying to learn Segment Trees from the following resource. http://www.geeksforgeeks.org/segment-tree-set-1-sum-of-given-range/
I tried building the segment tree first. However I am facing a doubt. When I use the array as 1,2,3,4,5,6 to build my segment tree I noticed that the tree array has value 0 at index 9 and 10(garbage values). Since I declared the tree array of a larger size and tree has only 11 nodes there are 2 indexes missing and are not calculated in the code. (At index 2 it becomes constructSTUtil(arr,2,2,st,4) and from there it does not calculate the values of indexes 9 and 10)
Is this a wrong code at the link above or am I missing something.!
Code on Ideone: http://ideone.com/xzurlR
Why is the last element in the tree array 0? The tree should have 11 nodes and I have put the limits accordingly while printing out the tree array.