Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 4 This is the code review task. Many typesetting systems have the functionality to justify tex. This prac sheet was created with STEX, which
Task 4 This is the code review task. Many typesetting systems have the functionality to justify tex. This prac sheet was created with STEX, which by default "ustifies" each line deciding where to break a sequence of words Design an algorithmic strategy to determine line break locations Nobe: Pense Resd the prublem stae- ment carefiuly a few times. Take notes Before asking any questions make list af all qaestiorw yau hase and try to answer them. When asking a question state what yu tried, or haw you atlemptad to salv. Study the robiem Every arrangement of lines will add some extra spaces in each line to make the text nice and tidy. You do no need to add the spaces, it is sufficient to determine the line breaks. For simplicity we w ignore hyphenation and assume a line break can only occur after a complete word Consider the text: "you can use dynamic programming to justify text and I ened that in FITio8" Here's one possibke arrangement (let's call it example): You can use dynamic to justify text and I learned that in FIT1008 Here's another possible arrangement (let's call it example 2: you can use dynanic to justify text and I learned that in FIT1008 FIT1008 -INTRO TO COMPUTER SCIENCE WORKSHOP WEEK 10 3 The idea is to obtain lines that are balanced. This is often achieved by minimising a cost function. Suppose you are given a list of words, -(. as wl as a line width M. A common cost function is C(L-'-f-1 e,, with ci-r'. Here ci is the cost of line,, when x is the unused space in the line. A line running from word ito word has x(i,j) = M Ep 1en(4) . Given as input a list of words W = [,wl,.-.,,-1, and a width M , determine what constitutes a solution to the "justification" problem. How can you use dynamic programming to find the optimal cost? Implement your DP solution. How can you use dynamic programming to find the optimal arrangement? Implement your solution. . Optional: Implement a print tidy(text, N function that nicely prints out the text with width M Optional: Why does the cost function ork well? What ust using cx . Optional: Add a ustify functionality to the editor from the previous prac. Task 4 This is the code review task. Many typesetting systems have the functionality to justify tex. This prac sheet was created with STEX, which by default "ustifies" each line deciding where to break a sequence of words Design an algorithmic strategy to determine line break locations Nobe: Pense Resd the prublem stae- ment carefiuly a few times. Take notes Before asking any questions make list af all qaestiorw yau hase and try to answer them. When asking a question state what yu tried, or haw you atlemptad to salv. Study the robiem Every arrangement of lines will add some extra spaces in each line to make the text nice and tidy. You do no need to add the spaces, it is sufficient to determine the line breaks. For simplicity we w ignore hyphenation and assume a line break can only occur after a complete word Consider the text: "you can use dynamic programming to justify text and I ened that in FITio8" Here's one possibke arrangement (let's call it example): You can use dynamic to justify text and I learned that in FIT1008 Here's another possible arrangement (let's call it example 2: you can use dynanic to justify text and I learned that in FIT1008 FIT1008 -INTRO TO COMPUTER SCIENCE WORKSHOP WEEK 10 3 The idea is to obtain lines that are balanced. This is often achieved by minimising a cost function. Suppose you are given a list of words, -(. as wl as a line width M. A common cost function is C(L-'-f-1 e,, with ci-r'. Here ci is the cost of line,, when x is the unused space in the line. A line running from word ito word has x(i,j) = M Ep 1en(4) . Given as input a list of words W = [,wl,.-.,,-1, and a width M , determine what constitutes a solution to the "justification" problem. How can you use dynamic programming to find the optimal cost? Implement your DP solution. How can you use dynamic programming to find the optimal arrangement? Implement your solution. . Optional: Implement a print tidy(text, N function that nicely prints out the text with width M Optional: Why does the cost function ork well? What ust using cx . Optional: Add a ustify functionality to the editor from the previous prac
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