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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -