Question: What I have so far: Problem 2: In a word processor, the goal of pretty-printing is to take text with a ragged right margin, like

 What I have so far: Problem 2: In a word processor,

What I have so far:

the goal of "pretty-printing" is to take text with a ragged right

Problem 2: In a word processor, the goal of "pretty-printing" is to take text with a ragged right margin, like this, me Ishma Some years ago, never mind how long precisely, having little or no money in my purse and nothing particular to interest me on shore I thought I would sail about a little and see the watery part of the world and turn it into text whose right margin is as "even" as possible, like this. ome years ago, never mind how long precisely, having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world To make this precise enough for us to start thinking about how to write a pretty-printer for text, we need to figure out what it means for-the right margins to be "even." So sup- pose our text consists of a sequence of words, W, w wn, where w consists of ci characters, we have a maximum line length of LWewil assume we have a fixed-width font and ignore issues of punctuation or hyphenation A formatting of W consists of a partition of the words in w, E W into lines. In the words assigned to a single line, there should be space after each word except the last; and so if wj, Wj+,.. .,wk are assigned to one line, then we should have k-1 We wil call an assignment of words to a line valid if it satisfies this y. The difference beteen the left-hand side and the right-hand side w be called the slack of A) Give a recurrence relation, tabular computation and trace back procedure for this B) Give an efficient dynamic programming algorithm to find a partition of a set of the line that is, the number of spaces left at the right margin problem words W into valid nes, so that the sum of the squares of the slacks of a es (including the last line) s ized Let s, represent the slack of line i, you are trying to minimize where m is the number of lines

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!