演算法›Ch3 動態規劃第 31 題/共 40 題
31. Dynamic Programming、String Shuffle、Pseudocode 填空
#AL-03-031中Dynamic ProgrammingString ShufflePseudocode 填空
(10%) Given three strings , and . We say that is a shuffle of and if it contains all characters of and and the left-to-right ordering of the characters from and the characters from is preserved. For example, "NcCKsiUe" is a shuffle of "NCKU" and "csie". The dynamic programming algorithm uses a table to check , and , where is true if and only if the first characters of are a shuffle of the first characters of together with the first characters of . Complete the following pseudocode for checks whether is a shuffle of and by filling (1), (2) and (3). (please use C-style expression)
isShuffle(x, y, z)
Let S[0...n][0...m] be a new table
S[0][0] = true
if r != n + m
return false
for i = 1 to n
S[i][0] = ____(1) (3%)____
for j = 1 to m
S[0][j] = ____(2) (3%)____
for i = 1 to n
for j = 1 to m
S[i][j] = ____(3) (4%)____
return S[n][m]
📄 成大110
▤完整推導請見《WH 資工筆記 · 演算法》Ch3 動態規劃