Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 22, Problem 1P

(a)

Program Plan Intro

To prove the breath first search properties in an undirected graph.

(a)

Expert Solution
Check Mark

Explanation of Solution

In the undirected graph, breath first search follow properties as:

Suppose in the undirected graph an edge ( u , v ) is consider as forward or back edge then vertex ‘ u’ should occur before vertex ‘ v’ and edges associated with ‘ u’ should be explore before any other edge in breath first search. Thus, the edge ( u , v ) can be considered as the tree edge because there is no forward and backward edge in undirected graph BFS traversal.

In the breath first search, an edge must be a tree if [v.π]=u and this can be possible if [v.d]=[u.d]+1 . In this values of [ u.d ] and [ v.d ] cannot be changed after initialization. So, in the breath first search [v.d]=[u.d]+1 .

Therefore for every tree edge ( u, v ) in breath first search, [v.d]=[u.d]+1 .

If vertex ‘ u’ visit before vertex ‘ v’ , and edge ( u, v ) is cross edge. As the properties of tree edge and cross edge, vertex ‘ u’ visit before vertex ‘ v’ that means vertex ‘ v’ must be in the queue. Hence, from the given statement, it will follow the condition for the cross edge ( u, v ):

Therefore, [v.d]=[u.d]+1 or [v.d]=[u.d].

(b)

Program Plan Intro

To prove the breath first search properties in the directed graph.

(b)

Expert Solution
Check Mark

Explanation of Solution

Breath first search properties in the directed graph as follows:

An edge ( u, v ) is not the tree edge if the given graph G is directed. So, the graph will not contain the forward edge ( u, v ).

In the breath first search, an edge must be a tree if [v.π]=u and this can be possible if [v.d]=[u.d]+1 . In this values of [ u.d ] and [ v.d ] cannot be change after initialization. So, in the breath first search [v.d]=[u.d]+1 . Therefore, for every tree edge ( u, v ) in breath first search, [v.d]=[u.d]+1 .

If vertex ‘ u’ visit before vertex ‘ v’ , and edge ( u, v ) is cross edge. As the properties of tree edge and cross edge, vertex ‘ u’ visit before vertex ‘ v’ that means vertex ‘ v’ must be in the queue. Hence, from the given statement, it will follow the condition for the cross edge ( u, v ):

Therefore, [v.d]=[u.d]+1 or [v.d]=[u.d] .

By seeing the above statements, it is clear for all vertices, 0[v.d] .

In the breath first search, back edge (u, v) where vertex ‘v’ is the ancestor of vertex ‘u’ and from the given vertices if the drawn edge is larger than the other. Hence, [v.d][u.d] .

Therefore, for every back edge (u, v), 0[v.d][u.d] .

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
Let G = (V, E) be a connected, undirected graph, and let s be a fixed vertex in G. Let TB be the spanning tree of G found by a bread first search starting from s, and similarly TD the spanning tree found by depth first search, also starting at s. (As in problem 1, these trees are just sets of edges; the order in which they were traversed by the respective algorithms is irrelevant.) Using facts, prove that TB = TD if and only if TB = TD = E, i.e., G is itself a tree.
(a) Adjacency list and adjacency matrix are two standard ways to represent graphs. Show the space consumption, the cost to count the number of edges in the graph and the cost to check the existence of an edge with adjacency list and adjacency matrix respectively. (b) In Fig. 1 is an undirected graph ?1. Show the sequence of nodes in the breadth-first traversal starting from node ?1, assuming that the neighbor nodes in the adjacency list of each node are in increasing order.
Answer True or False to the following claims: a. If G is graph on at most 5 vertices and every vertex has degree 2, then G is a cycle.   b. Let G be a forest. If we add an edge to G, then G is no longer a forest.   c. Let G be a graph, and let u, v, and w be vertices in G. Suppose that a shortest path from u to v in G is of length 3, andsuppose that a shortest path from v to w in G is of length 4. Then a shortest path from u to w in G is of length 7.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education