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 <abioy....@gmail.com> wrote:
> Hello,
>
> 2010/12/29 Anand <anandut2...@gmail.com>:
>
> > 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 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