Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Slide 1 1 of Lecture 2 0 : Solution 1 . Dynamic programming. Def. OPT ( i , j ) = length of LCS of

Slide 11 of Lecture 20:
Solution 1. Dynamic programming.
Def. OPT(i,j)= length of LCS of prefix strings x1x2dotsxi and y1y2dotsyj.
Goal. OPT(m,n).
Case 1.xi=yj.
1+ length of LCS of x1x2dotsxi-1 and y1y2dotsyj-1.
Case 2.xiyj.
Delete xi : length of LCS of x1x2dotsxi-1 and y1y2dotsyj.
Delete yj : length of LCS of x1x2dotsxi and y1y2dotsyj-1.
Bellman equation.
OPT(i,j)={0ifi=0orj=01+OPT(i-1,j-1)ifxi=yjmax{OPT(i-1,j),OPT(i,j-1)}ifxiyj
Slide 13 of Lecture 19:
Example
\table[[,,s,a,b
1. Given a digraph G =(V, E), its transitive closure G is a digraph defined as follows: It has the same vertex set V as G and contains an edge from a vertex a to another vertex b if and only if there is a directed path from a to b in G. Suppose we want to design a DP algorithm that outputs G on input G. Design the subinstances and the Bellman Equation. (Note that though this is not an optimization problem, DP is still helpful.)
2. Compute the shortest path from vertex 2 to every other vertex of the attached graph using the Bellman-Ford Algorithm. Show your work by constructing the table as in Slide 13 of Lecture 19.
3. Compute the length of longest common subsequence for the two input strings x = ABCBDAB and y = BDCABA using the dynamic programming algorithm on Slide 11 of Lecture 20. Show your work by filling the DP table.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions