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 B, Problem 1P
Program Plan Intro

To show that any tree is 2-colorable.

Expert Solution
Check Mark

Explanation of Solution

Given Information:

A Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  1of an undirected graph Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  2is a function Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  3such that Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  4for every edge Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  5

Explanation:

There are no loops in tree, if a color (0) is given to a node, then all its neighbors should be colored with a different color say color (1). Now color the neighbors of all these neighbors with color (0). In this way keep coloring alternating colors until the whole tree is colored. Since there are no loops no node will be visited and thus colored twice. In the end any path in the tree has vertices with alternating colors.

Program Plan Intro

To show that the following are equivalent:

  1. G is bipartite.
  2. G is 2-colorable.
  3. G has no cycles of odd length.

Expert Solution
Check Mark

Explanation of Solution

A bipartite graph has two sets of vertices which has equal number of vertices in those two sets. So, if the given graph G is bipartite that means it will be 2 colorable because one set of vertices can be colored with one color say color (0) and another set of vertices can be colored with another set of vertices say color (1).

The following figure shows the bipartite graph with chromatic numberIntroduction to Algorithms, Chapter B, Problem 1P , additional homework tip  6

  Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  7

Also, it can be seen that it has no cycles of odd length from the above figure of bipartite graph.

So, on the basis of above illustration- the following points can be made-

  1. G is bipartite.
  2. G is 2-colorable.
  3. G has no cycles of odd length.
Program Plan Intro

To prove that a Graph can be colored with Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  8colors where Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  9is the maximum degree of any vertex in graph.

Expert Solution
Check Mark

Explanation of Solution

Greedy coloring procedure requires us to number the colorsthat are used. So, each time a new color is introduced it is numbered.

Greedy coloring algorithm:

If the maximum degree vertex of a graph has degree d, let this vertex be v.

Color v with color 1.

Since all the adjacent vertices of 'v' have to be colored with a color other than color of 'v', let us assume that all the adjacent vertices are colored with different colors.

As number of neighbors is d, hence number of additional colors required is d. So, maximum d+1 colors are needed.

This is the maximum number of colors needed because in no case there will be more than d+1 colorsas the maximum degree is d. (All the neighbors and other nodes of graph have degree <= d)

Proof by mathematical induction:

Base case: A graph with just 1 vertex has maximum degree 0 and needs only 1 color. It is 1-colorable.

Inductive hypothesis: It can be assumed that any graph which has = k vertices and maximum vertex degree = d can be colored with d+1 colors.

Inductive Step: Now suppose there is a graph G with k+1 vertices and maximum degree d. Remove a vertex v (and all its edges) from G to create a smaller graph G'.

The maximum degree of G' is not greater than d, because removing a vertex from G' won't increase its degree. So, by the inductive hypothesis, G' can be colored with d + 1 colors. The neighbors of v are only using d of the available colors because v has maximum d neighbors, leaving a spare color that can be assigned to v.

Therefore, the coloring of G is an extension of coloring of G'. Hence, G can be colored with d+1 colors. G is (d+1)-colorable.

Program Plan Intro

To show that a graph G can be colored with Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  10if it has Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  11edges.

Expert Solution
Check Mark

Explanation of Solution

Run the above greedy algorithm when a colorIntroduction to Algorithms, Chapter B, Problem 1P , additional homework tip  12is used for the first time, to color a vetexIntroduction to Algorithms, Chapter B, Problem 1P , additional homework tip  13mark the edges joining Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  14to vertices already coloured which is atleastIntroduction to Algorithms, Chapter B, Problem 1P , additional homework tip  15

Every marked edge is marked only once during the process and at least Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  16edges will be marked when number of colors are used. So if number of colors are present, then number of edges will be colored. Introduction to Algorithms, Chapter B, Problem 1P , additional homework tip  17

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
1-2.A _______ is a connected, simple graph that has no cycles. Vertices of degree 1 in a tree are called the _______ of the tree. 3. The _______- graph on n nodes, denoted Kn, is the simple graph with nodes {1, . . . , n} and an edge between every pair of distinct nodes. 4. A graph is called ________ if its set of nodes can be partitioned into two disjoint sets S1 and S2 so that every edge in the graph has one endpoint in S1 and one endpoint in S2.
Throughout, a graph is given as input as an adjacency list. That is, G is a dictionary where the keysare vertices, and for a vertex v,G[v] = [u such that there is an edge going from v to u].In the case that G is undirected, for every edge u − v, v is in G[u] and u is in G[v]. 3. Write the full pseudocode for the following problem.Input: A directed graph G, and an ordering on the vertices given in a list A.Output: Is A a topological order? In other words, is there an i, j such that i < j and there is an edge fromA[j] to A[i]?
5. (This question goes slightly beyond what was covered in the lectures, but you can solve it by combining algorithms that we have described.) A directed graph is said to be strongly connected if every vertex is reachable from every other vertex; i.e., for every pair of vertices u, v, there is a directed path from u to v and a directed path from v to u. A strong component of a graph is then a maximal subgraph that is strongly connected. That is all vertices in a strong component can reach each other, and any other vertex in the directed graph either cannot reach the strong component or cannot be reached from the component. (Note that we are considering directed graphs, so for a pair of vertices u and v there could be a path from u to v, but no path path from v back to u; in that case, u and v are not in the same strong component, even though they are connected by a path in one direction.) Given a vertex v in a directed graph D, design an algorithm for com- puting the strong connected…
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