We can make a query tree and then each query will take O(log n+k) time.

On Wed, Mar 31, 2010 at 12:48 PM, Anil Kishore <[email protected]> wrote:
> What do you mean by points ? .. Are you referring to the integer values
> stored ?
> .
> 1.) If the question is, given N integers.. and given x1 and x2, report all
> integers x (x1<=x<=x2), you can't do better than O(N), as going through
> input itself takes O(N).
> .
> 2.) if the question is, given N integers and Q queries, each query is as
> ques1, then you may sort it initially and answer each query. It will be O( N
> log N ) + Q . O ( logN + (x2-x1) ).
> - AK
> On Wed, Mar 31, 2010 at 4:59 AM, Priyanka Chatterjee <[email protected]>
> wrote:
>>
>> Design an efficient algorithm to report all the points within x1 and x2
>> from a list of N integers.
>> What data structure will you use to implement this algorithm?
>> Find the order of complexity . ( An O(N) solution is not asked)
>>
>>
>> --
>> Thanks & Regards,
>> Priyanka Chatterjee
>> Third Year Undergraduate Student,
>> Computer Science & Engineering,
>> National Institute Of Technology,Durgapur
>> India
>> http://priyanka-nit.blogspot.com/
>>
>> --
>> 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.
>
>
>
> --
> Anil Kishore
>
> --
> 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.

Reply via email to