6. The input to this problem consists of an ordered list of n words. The length...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
6. The input to this problem consists of an ordered list of n words. The length of the ith word is wi, that is the ith word takes up w; spaces. (For simplicity assume that there are no spaces between words.) The goal is to break this ordered list of words into lines; this is called a layout. Note that you cannot reorder the words. The length of a line is the sum of the lengths of the words on that line. The maximum line length is L. Assume that w; L for all i. No line may be longer than L, although it may be shorter. The penalty for having a line of length K < L is L - K. Consider the following greedy algorithm. For i = 1 to n Place the ith word on the current line if it fits else place the ith word on a new line (a) The overall penalty is defined to be the sum of the line penalties. The problem is to find a layout that minimizes the overall penalty. Prove of disprove that the above greedy algorithm correctly solves this problem. (b) The overall penalty is now defined to be the maximum of the line penalties. The problem is to find a layout that minimizes the overall penalty. Prove of disprove that the above greedy algorithm correctly solves this problem. 6. The input to this problem consists of an ordered list of n words. The length of the ith word is wi, that is the ith word takes up w; spaces. (For simplicity assume that there are no spaces between words.) The goal is to break this ordered list of words into lines; this is called a layout. Note that you cannot reorder the words. The length of a line is the sum of the lengths of the words on that line. The maximum line length is L. Assume that w; L for all i. No line may be longer than L, although it may be shorter. The penalty for having a line of length K < L is L - K. Consider the following greedy algorithm. For i = 1 to n Place the ith word on the current line if it fits else place the ith word on a new line (a) The overall penalty is defined to be the sum of the line penalties. The problem is to find a layout that minimizes the overall penalty. Prove of disprove that the above greedy algorithm correctly solves this problem. (b) The overall penalty is now defined to be the maximum of the line penalties. The problem is to find a layout that minimizes the overall penalty. Prove of disprove that the above greedy algorithm correctly solves this problem.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
You work in the finance department of a telecommunications firm with a large direct sales force selling high- speed fiber optics access lines to companies wanting telephone and Internet access. Your...
-
Describe the role of culture within the Save the Children organization. How does this culture impact the hiring process at Save the Children?
-
If the gravitational field of Earth were to increase, would a fish float to the surface, sink, or stay at the same depth?
-
If the average output of the PV system in Problem 6.7 is \(200 \mathrm{~W}\), the load is changed to run during the day, how much PV output energy is needed for the same load conditions? Assume that...
-
BONDS ISSUED AT A PREMIUM Velez Entertainment Co. issued the following bonds at a premium: Date of issue and sale: .........April 1, 20-1 Principal amount: ...........$500,000 Sale price of bonds:...
-
.. Given a set of particles in the plane with position vectors F1, T2, Tn and masses m, m2, ..., mn, the position vector of the center of mass of the system is Tem Mm+m2 + +mn. = (mir+m2r2+ + mnrn),...
-
Consider the Markov chain in Figure 11.32. There are two recurrent classes, R 1 = {1, 2}, and R 2 = {5, 6, 7}. Assuming X 0 = 4, find the probability that the chain gets absorbed to R 1 . 1 S AL 1 1...
-
1) Sexton Inc. is considering Projects S and L, whose cash flows are shown below. These projects are mutually exclusive, equally risky, and not repeatable. If the decision is made by choosing the...
-
What pressure gradient along the streamline, \(d p / d s\), is required to accelerate water in a horizontal pipe at a rate of \(30 \mathrm{~m} / \mathrm{s}^{2}\) ?
-
A 2-ft-diameter hemispherical plexiglass "bubble" is to be used as a special window on the side of an above-ground swimming pool. The window is to be bolted onto the vertical wall of the pool and...
-
Give an example in which more than one priority rule is used simultaneously to create a sequence.
-
At a given location the airspeed is \(20 \mathrm{~m} / \mathrm{s}\) and the pressure gradient along the streamline is \(100 \mathrm{~N} / \mathrm{m}^{3}\). Estimate the airspeed at a point \(0.5...
-
Job Alpha is due in 4 weeks. If the flowtime for this job is 2 weeks, what is this job's tardiness?
-
In 2000, Michael purchased land for $100,000. Over the years, economic conditions deteriorated, and the value of the land declined to $60,000. Michael sells the property in this year, when it is...
-
Sue Deliveau opened a software consulting firm that immediately paid $2,000 for a computer. Was this event a transaction for the business?
-
A stepped bar, fixed at \(x=0\) and free at \(x=l\), has a cross-sectional area of \(2 A\) for \(0 \leq x
-
Estimate the fundamental frequency for the longitudinal vibration of a uniform bar fixed at \(x=0\) and free at \(x=l\) by assuming the mode shapes as (a) \(U(x)=c_{1}(x / l)\) and (b) \(U(x)=c_{1}(x...
-
Estimate the fundamental frequency of a fixed-fixed string, assuming the mode shape (a) \(W(x)=c_{1} x(l-x)\) and (b) \(W(x)=c_{1} x(l-x)+c_{2} x^{2}(l-x)^{2}\).
Study smarter with the SolutionInn App