Move all occurrence of letter ' x ' from the string s to the end using Recursion | Recursive program to bring ' x ' to the end ; When the string is completed from reverse direction end of recursion ; If the character x is found ; Transverse the whole string ; Swap the x so that it moves to the last ; Call to the smaller problem now ; Driver code ; Size of a ; Call to rec
def rec ( a , i ) : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT a . pop ( ) NEW_LINE print ( " " . join ( a ) ) NEW_LINE return NEW_LINE DEDENT if ( a [ i ] == ' x ' ) : NEW_LINE j = i NEW_LINE while ( a [ j ] != ' \0' and a [ j + 1 ] != ' \0' ) : NEW_LINE INDENT ( a [ j ] , a [ j + 1 ] ) = ( a [ j + 1 ] , a [ j ] ) NEW_LINE j += 1 NEW_LINE DEDENT rec ( a , i - 1 ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = [ ' g ' , ' e ' , ' e ' , ' k ' , ' x ' , ' s ' , ' x ' , ' x ' , ' k ' , ' s ' , ' \0' ] NEW_LINE n = 10 NEW_LINE rec ( a , n - 1 ) NEW_LINE DEDENT