Answer: provided in the explanation section
Explanation:
Given that:
Assume D(k) =║ true it is [1 : : : k] is valid sequence words or false otherwise
now the sub problem s[1 : : : k] is a valid sequence of words IFF s[1 : : : 1] is a valid sequence of words and s[ 1 + 1 : : : k] is valid word.
So, from here we have that D(k) is given by the following recorance relation:
D(k) = ║ false maximum (d[l]∧DICT(s[1 + 1 : : : k]) otherwise
Algorithm:
Valid sentence (s,k)
D [1 : : : k] ∦ array of boolean variable.
for a ← 1 to m
do ;
d(0) ← false
for b ← 0 to a - j
for b ← 0 to a - j
do;
if D[b] ∧ DICT s([b + 1 : : : a])
d (a) ← True
(b). Algorithm Output
if D[k] = = True
stack = temp stack ∦stack is used to print the strings in order
c = k
while C > 0
stack push (s [w(c)] : : : C] // w(p) is the position in s[1 : : : k] of the valid world at // position c
P = W (p) - 1
output stack
= 0 =
cheers i hope this helps !!!