Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Discrete Structure: only the first and fifth photo are questions, the rest is just information and example 1. Exercise 9.3.4: Apply the Breadth First Search
Discrete Structure: only the first and fifth photo are questions, the rest is just information and example
1. Exercise 9.3.4: Apply the Breadth First Search (BFS) algorithm (9.3.8) to determine the shortest path from vertex a to vertex i in the two graphs shown in Figure 9.3.12 (p. 213). Display the results of applying the algorithm using a table like the one shown in Example 9.3.10. in the totd tietherarti Algorithm 9.3.8 Breadth-first Search. A broadcasting algorithm for finding a path between verter i and verter j of a graph having n vertices. Each item Vk of a list V = {V1, V2, ...,Vn}, consist of a Boolean field Vi found and an integer field V.from. The sets Di, D2,..., called depth sets, have the property that if ke Dr, then the shortest path from verter i to verter k is of length r. In Step 5, a stack is used to put the verter list for the path from the verter i to verter j in the proper order. (1) Set the value V found equal to False, k = 1,2,...,n (2) r = 0 (3) Do = {i} (4) while (-V, found) and (D, +) D.+1 = 0 for each k in D, : for each edge (kt): If Vi found == False: V. Found - True V from D-1 - D1 {} (5) IV, found: CHAPTER 9. GRAPH THEORY 210 S = Empty Stack while Vi.from *i: Push k onto S k - V from This algorithm will produce one path from vertex i to vertex j, if one exists, and that path will be as short as possible. If more than one path of this length exists, then the one that is produced depends on the order in which the edges are examined and the order in which the elements of D, are examined in Step 4. The condition D, 7 ) is analogous to the condition that no mail is sent inn given stage of the process, in which case MISU cannot be connected to ESU. This algorithm can be easily revised to find paths to all vertices that can be reached from vertex Step 5 would be put off until a specific path to a vertex is needed since the information in contains an efficient list of all paths. The algorithm can also be extended further to find paths between two verticus. List 9.3.9 Figure 9.3.11: A simple example of breadth-first search Suppose that the edges from each vertex are sorted in ascending order by terminal vertex. For example, the edges from vertex 3 would be in the order (3.1). (3.4). (3.5). In addition, assume that in the body of Step 4 of the algorithm, the elements of D, are used in ascending order. Then at the end of Step 1. the value of l will be 1.found TTTTTT from 2 16 Depthset 13223 Then wanted the path (2.1.1. to ) i pro by the algorithm. Note that we the fonton m e the path Figure 9.3.12: Shortest paths hom te 1. Exercise 9.3.4: Apply the Breadth First Search (BFS) algorithm (9.3.8) to determine the shortest path from vertex a to vertex i in the two graphs shown in Figure 9.3.12 (p. 213). Display the results of applying the algorithm using a table like the one shown in Example 9.3.10. in the totd tietherarti Algorithm 9.3.8 Breadth-first Search. A broadcasting algorithm for finding a path between verter i and verter j of a graph having n vertices. Each item Vk of a list V = {V1, V2, ...,Vn}, consist of a Boolean field Vi found and an integer field V.from. The sets Di, D2,..., called depth sets, have the property that if ke Dr, then the shortest path from verter i to verter k is of length r. In Step 5, a stack is used to put the verter list for the path from the verter i to verter j in the proper order. (1) Set the value V found equal to False, k = 1,2,...,n (2) r = 0 (3) Do = {i} (4) while (-V, found) and (D, +) D.+1 = 0 for each k in D, : for each edge (kt): If Vi found == False: V. Found - True V from D-1 - D1 {} (5) IV, found: CHAPTER 9. GRAPH THEORY 210 S = Empty Stack while Vi.from *i: Push k onto S k - V from This algorithm will produce one path from vertex i to vertex j, if one exists, and that path will be as short as possible. If more than one path of this length exists, then the one that is produced depends on the order in which the edges are examined and the order in which the elements of D, are examined in Step 4. The condition D, 7 ) is analogous to the condition that no mail is sent inn given stage of the process, in which case MISU cannot be connected to ESU. This algorithm can be easily revised to find paths to all vertices that can be reached from vertex Step 5 would be put off until a specific path to a vertex is needed since the information in contains an efficient list of all paths. The algorithm can also be extended further to find paths between two verticus. List 9.3.9 Figure 9.3.11: A simple example of breadth-first search Suppose that the edges from each vertex are sorted in ascending order by terminal vertex. For example, the edges from vertex 3 would be in the order (3.1). (3.4). (3.5). In addition, assume that in the body of Step 4 of the algorithm, the elements of D, are used in ascending order. Then at the end of Step 1. the value of l will be 1.found TTTTTT from 2 16 Depthset 13223 Then wanted the path (2.1.1. to ) i pro by the algorithm. Note that we the fonton m e the path Figure 9.3.12: Shortest paths hom te Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started