Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dynamic Programming Let G = (V,E) be a directed graph with nodes v 1 ,...,v n . We say that G is an ordered graph

Dynamic Programming

Let G = (V,E) be a directed graph with nodes v 1 ,...,v n . We say that G is an ordered graph if it has the following properties. (i) Edges go from a node with a lower index to a node with a higher index. In other words, every directed edge has the form (v i ,v j ) with i < j. (ii) Each node with the exception of v n has at least one edge leaving it. In other words, for every node v i ,i = 1,2,...,n 1, there is at least one edge of the form (v i ,v j ). (a) Show that the following algorithm does not correctly solve this problem, by giving an example of an ordered graph on which it does not return the correct answer. Set a = v 1 Set L = 0 While there is an edge out of node a Choose the edge (a,v j ) for the smallest possible j Set a = v j Increase L by 1 Return L as the length of the longest path In your example, say both what the correct answer is and what the algorithm above finds. (b) Give an efficient algorithm that takes an ordered graph G and returns the length of the longest path that begins at v 1 and ends at v n .

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions