My two cents: You use bsearch in the first array for each element of second array!!
Wladimir Araujo Tavares *Federal University of CearĂ¡ * On Wed, Dec 29, 2010 at 3:05 PM, siva viknesh <[email protected]>wrote: > 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]<algogeeks%[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.
