Question: In a string of length n , the computational cost of splitting between index i and i + 1 ( indexed from 1 ) is
In a string of length n the computational cost of splitting between index i and i indexed from is n for any index i Call such an operation a split at i If you want to split your string into multiple pieces, this means it matters what order you perform the splits in Formally: Input: A string s s sn and split locations l l lk lk nNote: We are defining l and lk for your convenience later. Output: The smallest cost of splitting at l lk over all orderings of the splits. Example: s axdf jkl l l This means we need to split the string s into substrings a xdf and jkl If we start with the split at we incur a computational cost of for the first split, plus for the second, for total. If we split at then instead, we incur which is preferable. Heres a helpful subproblem for this problem. Let OPTi j be the minimum cost of splitting the substring sli slj at each of li lj Give a dp algo
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
