We define a function shuffleString(s: String): String that, given an input string s, does the following: If the string s is empty or length 1, the result is the same as input string s. Let n be the length of s. Recursively call shuffleString on the substring s (n/2)... s(n-1). Let s1 be the result Concatenate s1 to the first half s(0)..s(n/2-1) to the result of the call. Here is an implementation of this function and some examples, for your reference. (61: def shuffleString(s: String): String- val n s.length if(n < 1) { s } else val secondHalf s.substring(n/2, n) val shuffledHalfshufflestring(secondHalf.) val firstHalf s.substring(, n/2) return shuffledHalf firstHalf val fo-shuffleString(1234) val f1 shuffleString(12345) val f2shuffleString(123456) val f3shuffleString(1234567) val f4-shuffleString(12345678) val f5 shuffleString(123456789) 61: 987561234 Implement a tail recursive version of shufflestring using an accumulator variable. It will help to carefully examine how different parts of the string get rearranged to design this function or even first try to write a simple while loop that mimics shufflestring

If possible in scala, but pseudocode will work as well

We define a function shuffleString(s: String): String that, given an input string s, does the following: If the string s is empty or length 1, the result is the same as input string s. Let n be the length of s. Recursively call shuffleString on the substring s (n/2)… s(n-1). Let s1 be the result Concatenate s1 to the first half s(0)..s(n/2-1) to the result of the call. Here is an implementation of this function and some examples, for your reference. (61: def shuffleString(s: String): String- val n s.length if(n Show transcribed image text We define a function shuffleString(s: String): String that, given an input string s, does the following: If the string s is empty or length 1, the result is the same as input string s. Let n be the length of s. Recursively call shuffleString on the substring s (n/2)… s(n-1). Let s1 be the result Concatenate s1 to the first half s(0)..s(n/2-1) to the result of the call. Here is an implementation of this function and some examples, for your reference. (61: def shuffleString(s: String): String- val n s.length if(n