Computers and Technology

Chapter 6 problem 3: Let G = (V, E) be a directed graph with nodes v1,..., Vn. We say that G is an ordered graph if it has the following properties.
(1) Each edge goes from a node with a lower index to a node with a higher index. That is, every
directed edge has the form (vi, vy) with i (ii) Each node except v, has at least one edge leaving it. That is, for every node
Vi, i = 1,2,..., 1 - 1, there is at least one edge of the form (Vi, v;). The length of a path is the
number of edges in it. The goal in this question is to solve the following problem (see Figure 6.29 for
an example)
Given an ordered graph G, find the length of the longest path that begins at vi and ends at un
(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.

Figure 6.29 The correct answer for this ordered graph is 3: The longest path from v to
v, uses the three edges (U). Vs), (, Vs), and (V, Vs).
Set w=0
Set L = 0
While there is an edge out of the node w
Choose the edge (w, vy)
for which j is as small as possible
Set w = 0;
Increase L by 1
end while
Return L as the length of the longest path
In your example, say what the correct answer is and also what the algorithm above finds.
(b) Give an efficient algorithm that takes an ordered graph G and retums the length of the longest
path that begins at Uy and ends at vn (Again, the length of a path is the number of edges in the
path.)

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, lesok0818
Advantages and disadvantages of binary system
Answers: 1
image
Computers and Technology, 22.06.2019 11:00, dondre54
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, lokaranjan5736
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
image
Computers and Technology, 23.06.2019 18:30, erjalinalii
Janice recently received her college degree and is looking for a job. she is worried that since she just finished school, she will be required to repay her perkins and direct subsidized loans immediately. janice pulls out the paperwork she signed and reviews it again for repayment information. after reading all of the information, janice discovers that
Answers: 2
Do you know the correct answer?
Chapter 6 problem 3: Let G = (V, E) be a directed graph with nodes v1,..., Vn. We say that G is an...

Questions in other subjects:

Konu
Mathematics, 07.05.2020 03:13
Konu
Mathematics, 07.05.2020 03:13