I will try to give simple mathematical explanation.
Look at the code below . As per the segment tree implementation for range_query
int query(int node, int st, int end, int l, int r)
{
/*if range lies inside the query range*/
if(l <= st && end <= r )
{
return tree[node];
}
/*If range is totally outside the query range*/
if(st>r || end<l)
return INT_MAX;
/*If query range intersects both the children*/
int mid = (st+end)/2;
int ans1 = query(2*node, st, mid, l, r);
int ans2 = query(2*node+1, mid+1, end, l, r);
return min(ans1, ans2);
}
you go left and right and if its range then you return value.
So at each level 2 nodes are selected let's call LeftMost and rightMost. If say some other node is selected in between called mid one, then their least common ancestor must have been same and that range would have been included. thus
thus , For segment tree with logN levels.
Search at each level = 2
Total search = (search at each level ) * (number of levels) = (2logN)
Therefore search complexity = O(2logN) ~ O(logN).
P.S for space complexity (https://codeforces.com/blog/entry/49939 )