c++ - Retrieving maximum value from a range in unsorted array -
i have unsorted array. have numerous queries in give range (expressed 2 array indexes) , maximum value range (that is, specified slice of array) has returned. example:
array[]={23,17,9,45,78,2,4,6,90,1}; query(both inclusive): 2 6 answer: 78
which algorithm or data structure construct retrieve maximum value range. (there lot of queries)
edit: using c++
i think preprocessing allowed. range minimum query problem (maximum here). good review of problem @ topcoder. suitable data structures: segment tree , sqrt-decomposition
Comments
Post a Comment