Suppose you are given an array a[]={2,3,1,4,6,7,10}
now for successfully transferring the ball,from ith city to jth city,a[i] >
max(a[i..j-1]).
A naive approach would be to calculate all possible max[i][j] that is max
for each interval and then answer the query in 0(1) time.Another approach
would be to divide the array into powers of 2 and find the max for each
divided interval.Then answer each query in log n time..Finally you can
construct
a b tree with root node having the max of the array,the left and right child
having max of respectively max(a[0..i/2]) and max(a[i/2+1..i]) and so
on.Then answer each query in log(n) time for searching the right
interval....
So if
On Fri, Jun 10, 2011 at 6:28 PM, nicks <[email protected]> wrote:

> ya i saw that in the comments on spoj someone suggested to use RMQ....can
> you explain a bit moe how to implement RMQ and how it is helping in reducing
> the time !!
>
>
> On Fri, Jun 10, 2011 at 5:53 AM, saurabh singh <[email protected]>wrote:
>
>> Use Range Maximum Query.....
>>
>>
>> On Fri, Jun 10, 2011 at 4:15 PM, kartik sachan 
>> <[email protected]>wrote:
>>
>>> how should we get TLE loop total running less than 10^6??
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to