use counting sort.. it gives linear time complexity... first step of counting sort is the same as you have mentioned in question...
On Wed, Apr 18, 2012 at 6:37 PM, VIHARRI <[email protected]> wrote: > Can anybody give an O(n) algorithm for the following problem. > > Suppose if we have an array, I would like to construct an array with the > elements which specify their corresponding position in the sorted array. > > For example if the array is { 0.87, 0.04, 0.95, 0.12, 0.36 } then the > sorted array would be { 0.04, 0.12, 0.36, 0.87, 0.95 }. > Then output array would be {3, 0, 4, 1, 2 }. > > Hope I'm clear... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/NH1P0aIguFEJ. > 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. > -- Thanks and Regards: Rahul Kumar Patle M.Tech, School of Information Technology Indian Institute of Technology, Kharagpur-721302, India Mobile No: +91-8798049298, +91-9424738542 [email protected] [email protected] -- 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.
