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, 21.06.2019 16:00
What tool can discover and report computer errors and conflicts that occur when you first turn on a computer and before the operating system?
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
question
Computers and Technology, 23.06.2019 22:20
Read “suburban homes construction project” at the end of chapters 8 and 9 (in the textbook) and then develop a wbs (work breakdown structure) in microsoft excel or in microsoft word (using tables)
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. this can be done by normalizing to values between 0 and 1, or throwing away outliers. for this program, adjust the values by subtracting the smallest value from all the values. the input begins with an integer indicating the number of integers that follow. ex: if the input is 5 30 50 10 70 65, the output is: 20 40 0 60 55
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, 25.08.2021 22:00
question
Mathematics, 25.08.2021 22:00
question
English, 25.08.2021 22:00
question
Mathematics, 25.08.2021 22:00