Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. In word processor, the goal of pretty-printing is to take text with a a ragged right margin, like this, Call me Ishmael. Some years

image text in transcribed

6. In word processor, the goal of "pretty-printing" is to take text with a a ragged right margin, like this, Call me Ishmael. 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. Call me Ishmael. 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 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 suppose our text consists of a sequence of words, W-e(wl,Wy, . . . , wn), where wi consists of ci characters. We have a maximum line length of L. We wll 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 into lines. In the words assigned to a single line, there should be a space after each word except the last; and so if wj, Wti,.. . , wk are assigned to one line, then we should have We will call an assignment of words to a line valid if it satisfies this inequality. The difference between the left-hand side and the right-hand side will be called the slack of the line-that is, the number of spaces left at the right margin. Give an efficient algorithm to find a partition of a set of words W into valid lines, so that the sum of the squares of the slacks of all lines (including the last line is minimized

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions