subject

A string operation breaks a string into two pieces, which costs n time units for a string of n characters. When a string is broken into many pieces, the order in which the breaks occur can affect the total amount of time used. For example, to break a 20-character string after characters 2, 8, and 10 (numbering the characters in ascending order from the left-hand end, starting from 1). If the breaks to occur in left-to-right order, then the first break costs 20 time units, the second break costs 18 time units (breaking the string from characters 3 to 20 at character 8), and the third break costs 12 time units, totaling 50 time units. If the breaks to occur in right-to-left order, however, then the first break costs 20 time units, the second break costs 10 time units, and the third break costs 8 time units, totaling 38 time units. In yet another order, the first break is at 8 (costing 20), then the 2nd break is at 2 (costing 8), and finally the third break is at 10 (costing 12), for a total cost of 40. Given a string S with n characters and an array L[1..m] containing the break points in ascending order): (1) Formulate the recursive relation of the optimal solution; (2) Design a bottom-up algorithm to calculate the lowest cost for a sequence of breaks; (3) Analyze the complexity of your algorithm; (4) Write an algorithm to print out a sequence of breaks that achieves this cost.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
question
Computers and Technology, 24.06.2019 03:00
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
You know the right answer?
A string operation breaks a string into two pieces, which costs n time units for a string of n chara...
Questions
question
Mathematics, 15.08.2021 04:50
question
Mathematics, 15.08.2021 05:40
question
English, 15.08.2021 05:40
question
Mathematics, 15.08.2021 05:40
question
English, 15.08.2021 05:40
question
Physics, 15.08.2021 05:40
question
English, 15.08.2021 05:40
Questions on the website: 13722361