its similar to performing a right rotatate within the specifie boundary the number of times specified by argument
On Thu, Sep 16, 2010 at 11:49 PM, Aurelian Tutuianu <padre...@gmail.com>wrote: > A naive way to implement that is: > > int[] v = new int[100]; // this is my vector with values > > for (int i = v.length - 1; i >= 0; i++) { > // get maximum value > int max = Integer.MIN_VALUE; > for (int j = 0; j < v.length; j++) { > if (max < v[j]) { > max = j; > } > } > // put max value on first position > rev(max); > // put max value on proper position > rev(i); > } > > 2*n calls to rev. (the fact that the find max is a naive approach does > not count, according to problem) > > On Sep 16, 6:41 pm, Srinivas <lavudyasrinivas0...@gmail.com> wrote: > > You have been given a function rev(x) which works as follows: > > It reverses a[0] to a[x] elements of a. > > e.g. Given array is > > a : 1 8 3 4 5 > > rev(3) will convert the array to > > a : 4 3 8 1 5 > > Use this function only (and comparison, of course) to sort given array > > 'a'. The only criterion is > > that the number of times this function is called should be minimum. > > -- > 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<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- yezhu malai vaasa venkataramana Govinda Govinda -- 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.