public void inPlaceTransformationImproved(char str[]){
        int low=0;
        int size = str.length;
        while(size > 0){
            int end = get3PowerK1(size);
            size = size-end;
            CycleLeaderIteration cli = new CycleLeaderIteration();
            cli.iterate(str, low, end + low-1);
            low = low+end;
        }
        size = str.length;
        low =0;
        int end = get3PowerK1(size);
        while(end < str.length){
            int nextEnd = get3PowerK1(str.length-end);
            reverse(str,end/2,end-1);
            reverse(str,end/2,end+nextEnd/2-1);
            reverse(str,end/2,end/2+nextEnd/2-1);
    //      size = str.length - (end + nextEnd);
            end = end + nextEnd;
        }
    }
http://www.geeksforgeeks.org/an-in-place-algorithm-for-string-transformation/
src/com/interview/string/InPlaceTransformationOfString.java