1. Engineering
  2. Computer Science
  3. must be written in scala please...

Question: must be written in scala please...

Question details

must be written in Scala pleasedef shuffleString(s: String): String val n s.length() if(n <: 1) { s } else val secondHalfs.substring(n/2, n) val shuffledHalf shuffleString (secondHalf) val firstHalf s.substring(0, n/2) return shuffledHalf firstHalf val feshuffleString( 1234 val f1-shuffleString( 12345 val f2shuffleString(123456) val f3 shuffleString(1234567) val f4shuffleString(12345678 val f5shuffleString(123456789) 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 def tailRecursiveShuffleString(s: String, acc: String) String /YOUR CODE HERE assert (shuffleString()tailRecursiveShuffleString(1), Failed test 1 assert (shuffleString( 12tailRecursiveShuffleString( 12), passed (5) 12. Failed test 12 assert(shuffleString(123) tailRecursiveShuffleString( 123), assert (shuffleString( Failed test 123 tailRecursiveShuffleString 1234

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution