Question
A certain string-processing language allows the programmer to break a string into two pieces. Since this involves copying the old string, it costs units of
A certain string-processing language allows the programmer to break a string into two pieces. Since this involves copying the old string, it costs units of time to break a string of n characters into two pieces. Suppose a programmer wants to break a string into many pieces. The order in which the breaks are made can affect the total amount of time used. For example, suppose we wish to break a 20 character string after characters 3, 8, and 10 (numbering the characters in ascending order from the left-hand side, starting from 1). If the breaks are made in the left-to-right order, then the first break costs 20 units of time, the second break costs 17 units of time, and the third break costs 12 units of time, a total of 49 units of time. If the breaks are made in the right-to-left order, then the first break costs 20 units of time, the second break costs 10 units of time, and the third break costs 8 units of time, a total of 38 units of time.
a. Find a counterexample to the following algorithm for the problem above. Start by cutting the string as close to the middle as possible, and then repeat the same thing recursively in each half.
I need complete details and fully explained answer and algorithm with elaborated data structures if used any and if your algorithm calls any function you are expected to describe call function as well. and kindly reply fast as possible. exact answer to same question no relevant answers would be acceptable. Thanks.
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