Typesetting problem The input is a sequence of n words of lengths l1,l2,…,ln measured in…

Typesetting problem The input is a sequence of n words of lengths l1,l2,…,ln measured in characters. We want to print it nicely on a number of lines that can hold a maximum of M characters each. The criterion for ‘niceness’ is as follows. No word can be split across lines with a blank separating words and each line should be as full as possible. The penalty for a trailing space of s is s 3 . If si is the trailing space left in line i, we want to minimize _i s 3 i . If the penalty function is _i si , would a greedy approach work?