Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The paragraphing problem is: Given a set of words w _ 1 , . . . , w _ n with word lengths l _
The paragraphing problem is: Given a set of
words w wn with word lengths l ln break the words
into consecutive groups, such that the sum of the lengths of
the words in each group is less than a fixed value KWe
will ignore the issue of putting spaces between words or
hyphenation; these are minor details. The words remain
in the original order, so the task is just to insert line breaks
to ensure that each line is less than length K
The greedy algorithm for line breaking is to pack in as
many words as possible into each line, eg to put words
into a line one at a time until the length bound K is reached,
and break the line before the word wr that caused the the
bound to be exceeded.
Prove that the Greedy Algorithm is optimal in the sense
that it produces a paragraph with the smallest number of
lines. For a formal proof, induction is recommended. The
key to this problem is coming up with the right induction
hypothesis.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started