Discrete Mathematics

advertisement
Discrete Mathematics
October 27, 2004
Roll No.
Here is the bucket algorithm already discussed in the class:
Bucket-Algorithm (Input: a Graph G, Output: a Bucket B)
1. Put any vertex x of G in the Bucket B
2. While there are branches coming out of the Bucket B
3.
Choose an edge (u, v) connecting u in B to v not in B
4.
Put v in B
Assume that we want to find if a given graph H is connected. We shall use the
Bucket algorithm in the following way:
Connected Graph Algorithm (Input: Graph H, Output: Yes or No)
1. Run Bucket-Algorithm (H, B)
2. If there exists any vertex of H outside the Bucket B then
Return No (It is not connected)
Else Return Yes (It is connected)
Here is an algorithm to find if a given edge in a given graph is a bridge.
EdgeBridge (Input: A Graph and a given edge, Output: Yes or No)
1) Remove the given edge from the given graph.
2) If Connected Graph Algorithm output is Yes then
Return No (The edge is not a bridge)
Else Return Yes (The edge is a bridge)
1) Design an algorithm to find a bridge in a graph using the suitable building
blocks. Do not forget to derive its worst-case time complexity.
2) Design an algorithm to find if a given graph is a tree using the solution of the
above part. Again do not forget to derive its time complexity.
3) You can use the same building blocks to find a spanning tree of a graph?
Discuss briefly. Derive its time complexity.
Download