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
function rec ( a , i ) { if ( i == 0 ) { document . write ( a . join ( " " ) ) ; return ; } if ( a [ i ] == ' ' ) { let j = i ; while ( a [ j ] != ' \0 ' && a [ j + 1 ] != ' \0 ' ) { let temp = a [ j ] ; a [ j ] = a [ j + 1 ] ; a [ j + 1 ] = temp ; j ++ ; } } rec ( a , i - 1 ) ; } let a = [ ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' \0 ' ] ; let n = 10 ; rec ( a , n - 1 ) ;