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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -