Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7.Z rewritten (as a rewritten 7.27) Let G (V, E) be a DAG, and let each edge (u, v) in E have the positive length

image text in transcribed
7.Z rewritten (as a rewritten 7.27) Let G (V, E) be a DAG, and let each edge (u, v) in E have the positive length Ecost(u, v) > 0. We think of the length function Ecost(*, ) as running in constant-time for each edge. [One way to achieve this fast access is via a |VIx IVI array Ecost l.JVI, 1. VlI. But you cannot use arrays in an algori that runs in O( E +IVI) time because |El can be much less than IV]2. Th input data unless the graph contains about |VP edges. A better way to input the data is to enhance each adjacency list Adjlu to store not only the name v of each neighbor of u, but also the edge-length of the edge (u, v). So instead of thinking of Adjlu as a list of vertex names, we think of it as a list of pairs (vertezname, edgelength), so that an element in the U hat is, we should not spend IVI2 time reading the 2 (v, Ecost(u,")), where v is a neighbor of u, and Ecost(u, v) is the numerical length of edge (u, v)] Consequently, you can use pseudocode that accesses the length via the call Ecost(u, e), and ignore the lower-level and easily solved-coding issues about how store these values in a time-space efficient way a) Present a DFS that runs in e(V] EI) time and finds, for each vertex u in V, the largest length among all paths that begin at u and end at any of G's leaf-like vertices, which have no exiting edges. For each u in V, store the solution in the fied u.longestoutof

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

How would you define direct marketing?

Answered: 1 week ago