I think it can be done in logn time ( I assume the list is sorted, is there
an order log n sorting algo, then i can even sort it in log n time ? ( I am
new to algorithms ) ).

1. binary search for low=x1.
2. binary search for high=x2.

both will take log n time. Print all values between them then in O(x2-x1)
time.

Is this correct?
On Wed, Mar 31, 2010 at 12:58 PM, Rohit Saraf
<rohit.kumar.sa...@gmail.com>wrote:

> With only this info and without preprocessing , you need to scan all the N
> integers in the list atleast once. Hence cannot be better than O(n).
> If preprocessing is allowed you can compute the answers for all n^2 pairs
> of x1,x2 and when some one asks , return the corresponding list.
> In that case it would be better that O(n). !!
>
> -Rohit
>
>
>
>
> On Wed, Mar 31, 2010 at 4:59 AM, Priyanka Chatterjee 
> <dona.1...@gmail.com>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 algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> 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 algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to