Q:

finding min and max from a subset of a list of intervals

Given a list of intervals (shown here with their indexes):
0: 1,3
1: 0,4
2: 5,7
3: 6,9
4: 2,8

And then given an arbitrary in and out from the list indexes, is there a good way to determine the min and max value from the inclusive corresponding intervals? 
For example: 0,4 would give you 0,9.   2,3 would give you 5,9. 
My current solution involves iterating over every interval in range, keeping mins on the in-points and max on the out-points.   Wondering if there is a data structure of algorithmic technique I am overlooking to make this faster for when the list of intervals is very long.   As the list of intervals does not change, maybe there is some model I can create up front to represent the data differently? 

A:

As it can be easily seen that each interval actually indicates a min and a max value. 
So the problem becomes: give you 2 arrays, find the min and max value for any specified index ranges. 
finding min and max value are similar, so we talk about min here. 
First it can be easily done with Segment tree, just as @Vaughn Cato said. 
and actually we don't need to use a so powerful data structure like Segment tree, there's another specific algorithm to solve this, which is called Range Minimum Query. 
btw, i've written a post talking about RMQ, see http://attiix.com/2011/08/22/4-ways-to-solve-%c2%b11-rmq/.

