String formed with middle character of every right substring followed by left sequentially | Function to decrypt and print the new string ; If the whole string has been traversed ; To calculate middle index of the string ; Print the character at middle index ; Recursively call for right - substring ; Recursive call for left - substring ; Driver Code
def decrypt ( Str , Start , End ) : NEW_LINE INDENT if ( Start > End ) : NEW_LINE INDENT return ; NEW_LINE DEDENT mid = ( Start + End ) >> 1 ; NEW_LINE print ( Str [ mid ] , end = " " ) ; NEW_LINE decrypt ( Str , mid + 1 , End ) ; NEW_LINE decrypt ( Str , Start , mid - 1 ) ; NEW_LINE DEDENT N = 4 ; NEW_LINE Str = " abcd " ; NEW_LINE decrypt ( Str , 0 , N - 1 ) ; NEW_LINE print ( ) ; NEW_LINE N = 6 ; NEW_LINE Str = " gyuitp " ; NEW_LINE decrypt ( Str , 0 , N - 1 ) ; NEW_LINE