Introduction To Algorithms, Third Edition (international Edition)
Introduction To Algorithms, Third Edition (international Edition)
3rd Edition
ISBN: 9780262533058
Author: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
Publisher: TRILITERAL
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 1P

(a)

Program Plan Intro

To describe a dynamic-programming approach for finding longest simple path in directed acyclic graph and also give the running time of the algorithm.

(a)

Expert Solution
Check Mark

Explanation of Solution

Given Information:

The shortest closed tour of the graph with length approximately is 24.89. The directed acyclic graph is shown below-

Introduction To Algorithms, Third Edition (international Edition), Chapter 15, Problem 1P , additional homework tip  1

Explanation:

The dynamic-approach used to find the longest length simple path consider the graph G and vertices as V. The longest simple path must go through some edge of weight s or t . The algorithms to compute the longest weight path is longest(G,s,t)=1+max(longest(G,s',t)) .

The base condition for the algorithm is s=t and the initial length is 0.It can see that it consider this many possible sub-problems by taking |G| and complete graph on vertices V .

The algorithm to compute longest simple path in a directed acyclic graph is given below-

LONG-PATH(G,u,s,t,len)

If t==s then

set len(s)=0 .

return ( len,u )

else if u[s]==NULL then

Return (len,u).

else

for each adjacent vertex uG of s.

Check the distance after adding new vertex i.

if w(s,u)+len[u]len[s] then

  len[s]=w(s,u)+len[u] .

  u[s]=t .

end if.

end for.

end if.

return ( len,u ).

end.

In above algorithm, loop of for is used to determine the longest path and the longest path visit all vertex by checking all adjacent vertex.

The time taken by the algorithm is depends upon the number of vertex visited and the number of edges in the longest simple path. Suppose V represent the number of vertex used in the computing the longest simple path and E represent the number of edges then total running time of the algorithm is equals to O(V+E) .

(b)

Program Plan Intro

To describe a dynamic-programming approach for finding longest simple path in directed acyclic graph and also give the running time of the algorithm.

(b)

Expert Solution
Check Mark

Explanation of Solution

Given Information:

The shortest closed tour of the graph with length approximately is 25.58. The directed acyclic graph is shown below-

Introduction To Algorithms, Third Edition (international Edition), Chapter 15, Problem 1P , additional homework tip  2

Explanation:

The longest simple path must go through some edge of weight s . The base condition for the algorithm is s=t and the initial length is 0.It can see that it consider this many possible sub-problems by taking |G| and complete graph on vertices V .

The algorithm to compute longest simple path in a directed acyclic graph is given below-

LONG-PATH(G,u,s,t,len)

If t==s then

set len(s)=0 .

return ( len,u )

else if u[s]==NULL then

Return (len,u).

else

for each adjacent vertex uG of s.

Check the distance after adding new vertex i.

if w(s,u)+len[u]len[s] then

  len[s]=w(s,u)+len[u] .

  u[s]=t .

end if.

end for.

end if.

return ( len,u ).

end.

The time taken by the algorithm is depends upon the number of vertex visited and the number of edges in the longest simple path. Suppose V represent the number of vertex used in the computing the longest simple path and E represent the number of edges then total running time of the algorithm is equals to O(V+E) .

The above algorithm taken consideration of the nodes and generates the output according to the number of nodes in the graph so the longest length is computed by longest(G,s,t)=1+max(longest(G,s',t)) .

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Write a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question. In the student sample programs for this book, you will find a text file named 8_ball_responses.txt. The file contains 12 responses, such as “I don’t think so”, “Yes, of course!”, “I’m not sure”, and so forth. The program should read the responses from the file into a list. It should prompt the user to ask a question, then display one of the responses, randomly selected from the list. The program should repeat until the user is ready to quit. Contents of 8_ball_responses.txt:  Yes, of course! Without a doubt, yes. You can count on it. For sure! Ask me later. I'm not sure. I can't tell you right now. I'll tell you after my nap. No way! I don't think so. Without a doubt, no. The answer is clearly NO. (You can access the Computer Science Portal at www.pearsonhighered.com/gaddis.)
Start with the initial angles within the integration and just integrate them without mapping them to specific quadrants. Use python and radians
How does encryption prevent a hacker from getting your data
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Fundamentals of Information Systems
Computer Science
ISBN:9781305082168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage