. The input to this problem is a pair of strings A = a1   am and B = b1   bn. The goal is to convert A into B as cheaply as possible. The rules and cost are dened as follow. For a cost of 3 you can delete any letter. For a cost of 4 you can insert a letter in any position. For a cost of 5 you can replace any letter by any other letter. For example, you can convert A = abcabc to B = abacab via the following sequence: abcabc at a cost of 5 can be converted to abaabc, which at cost of 3 can be converted to ababc, which at cost of 3 can be converted to abac, which at cost of 4 can be converted to abacb, which at cost of 4 can be converted to abacab. Thus the total cost for this conversion would be 19. This is probably not the cheapest possible conversion. (Note that the Unix di command essentially solves this problem.) (a) Give a dynamic programming algorithm to solve this problem. (b) Apply your algorithm in (a) to convert A = abcabc to B = abacab with the minimum total cost. Show all your work.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

5. The input to this problem is a pair of strings A = a1   am and B = b1   bn. The goal is

to convert A into B as cheaply as possible. The rules and cost are dened as follow. For a

cost of 3 you can delete any letter. For a cost of 4 you can insert a letter in any position.

For a cost of 5 you can replace any letter by any other letter. For example, you can convert

A = abcabc to B = abacab via the following sequence: abcabc at a cost of 5 can be converted

to abaabc, which at cost of 3 can be converted to ababc, which at cost of 3 can be converted

to abac, which at cost of 4 can be converted to abacb, which at cost of 4 can be converted to

abacab. Thus the total cost for this conversion would be 19. This is probably not the cheapest

possible conversion. (Note that the Unix di command essentially solves this problem.)

(a) Give a dynamic programming algorithm to solve this problem.

(b) Apply your algorithm in (a) to convert A = abcabc to B = abacab with the minimum total

cost. Show all your work.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr