you can also go through the array printing the indexes, but what if I
want to know the indexes of some certain elements?

2010/12/30 siva viknesh <[email protected]>:
> if we sort the first array along with the indexes ...in the next pass
> we can directly print the indexes as result no
> ....why should we do binary search in the next pass considering that
> 2nd array is also sorted???
>
> On Dec 29, 11:38 am, Abioy Sun <[email protected]> wrote:
>> Hello,
>>
>> 2010/12/29 Anand <[email protected]>:
>>
>> > if I already have a structure indicating the position of the element in the
>> > array. Then why do we need to sort. Question is to provide index of element
>> > in O(nlogn).
>>
>> You do not have a structure before  preprocessing the data, whose
>> complexity  is O(nlogn) via qsort. Once you zip the zip the two array,
>> and sort the new array as @Wladimir and @juver++ mention, you can
>> provide each certain element's index in O(logn) via bsearch.
>
> --
> 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