An array of size N has distinct values 1...N in random order. You have only operator called rev(X) (where X is any value from 0 to N-1) which reverses all values from 0 to X (example values 2,3,1,4 and rev(2) gets you 1,3,2,4). Our objective is to sort the array using minimum number of Rev(X) functions. How many permutations of N size array require exactly N number of rev(X) operators to get sorted
a. For size 3 only 1,3,2 requires 3 moves. if any body previously posted this questions...iam sorry for that... actually someone asked me this questions i got one solution..but i dont wheather it uses min no of rev func calls PSUEDO CODE :::: initially i is n; find max no in [0-i] rev that function upto max ele position now max ele in first position now use rev (i) now max in nth position i--; now iam finding iteratively next max like that iam sorting..... is it efficient solution.. if any body knows or the gets the more efficient solutions... plz tel me... Ur frnd --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---