1. Given a strings and a dictionary (set of strings) D we want to split s into the substrings $1, S2, ..., Sk such that s; E D for all 1 ≤ i ≤ k. For example for s = catsanddog and D = {cat, cats, and, sand, dog} the two possible splits are (cats, and, dog) and (cat, sand, dog). (a) Design a backtracking algorithm that finds all the possible solutions to the problem that is, all the possible ways to split s into substrings from D. Establish the correctness and analyze the running times of your algorithm. Also comment on the optimality of your algorithm. (b) Modify the algorithm you developed in Question la so that it finds one split of s into substrings from D as efficiently as possible. Establish the correctness and analyze the running times of your algorithm. (c) Design an algorithm that finds efficiently a minimal split that is, a split s₁, S2, . .../ Sk of s such that s; Є D for all 1 ≤ i ≤ k and k is minimal. Establish the correctness and analyze the running times of your algorithm. (d) Design a nondeterministic algorithm that returns TRUE iff s can be split into substrings from D. Establish the correctness and analyze the running times of your algorithm.
1. Given a strings and a dictionary (set of strings) D we want to split s into the substrings $1, S2, ..., Sk such that s; E D for all 1 ≤ i ≤ k. For example for s = catsanddog and D = {cat, cats, and, sand, dog} the two possible splits are (cats, and, dog) and (cat, sand, dog). (a) Design a backtracking algorithm that finds all the possible solutions to the problem that is, all the possible ways to split s into substrings from D. Establish the correctness and analyze the running times of your algorithm. Also comment on the optimality of your algorithm. (b) Modify the algorithm you developed in Question la so that it finds one split of s into substrings from D as efficiently as possible. Establish the correctness and analyze the running times of your algorithm. (c) Design an algorithm that finds efficiently a minimal split that is, a split s₁, S2, . .../ Sk of s such that s; Є D for all 1 ≤ i ≤ k and k is minimal. Establish the correctness and analyze the running times of your algorithm. (d) Design a nondeterministic algorithm that returns TRUE iff s can be split into substrings from D. Establish the correctness and analyze the running times of your algorithm.