Answer:
The solution code is written in Python:
- def add_spaces(s):
- if len(s) < 2:
- return s
- else:
- return s[0] + " " + add_spaces( s[1 : ] )
Explanation:
Recursive function is a function that will call itself within the same function.
Let create a function named add_spaces() that take one input string, s (Line 1).
Next, create an if condition to check if the length of the input string is less than 2 (this means if the string has only one character), return the current string (Line 2-3).
Otherwise, it should return the first character of string, s[0] concatenated with a single space " " and concatenated again with the return output from the recursive calling add_spaces() that take s[1: ] as input parameter (Line 4-5). Please note s[1: ] is an expression we get the substring of the current string from position 1 till the end of string.
Henry Ford would have been most interested to bring assembly lines which is an modern innovation to his autmotive factories. Although Henry Ford didn't invent cars he developed assembly lines