Question: Shufe is a string problem that can be solved in recursion. Specically, let 51 and 52 be two strings. We can form a new shuffled


Shufe is a string problem that can be solved in recursion. Specically, let 51 and 52 be two strings. We can form a new shuffled string by interspersing the chars in 51 and s2 into a new string and preserving the order in which the chars appear in s1 and 52. For example, the strings spa and 5m can be shuffled into many new strings including the following... spa 5 m which results in the string sspma. Here*s another possible valid shuffle of these strings... spa sm which results in the string spasm. (Interestingly, we could NOT have made the string spasm had we started by using the rst 5 in 5m because then we would have had to use the first s in spa before using the p in spa.) The shuffle{string 51, string 52, string s3) returns true if 51 and s2 can be shufed to make s3 and returns false otherwise. You may assume that none of the initial strings 51, 52, and 53 is an empty string. E#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
