1 / 110100%
POLYNOMIAL-TIME REDUCTIONS AND NP-COMPLETENESS IN
SECURITY PROBLEMS
1.1 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
1. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
3. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.2 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
1. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
2. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
1. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
2. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.3 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
1. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
3. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.4 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
1. Define the problem of deciding whether a given graph is planar as a decision problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
3. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.5 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
1. Define the problem of deciding whether a given graph is bipartite as a decision problem.
2. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
1. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
2. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.6 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
1. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
3. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.7 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
1. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
3. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.8 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
1. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
2. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
3. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
1. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
2. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
3. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.9 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
4. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
5. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
6. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
7. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
8. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
9. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.10 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
10. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
11. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
12. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
13. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.11 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
14. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
15. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
16. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
17. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
18. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
19. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.12 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
20. Define the problem of deciding whether a given graph is planar as a decision problem.
21. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
22. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
23. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
24. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
25. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.13 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
26. Define the problem of deciding whether a given graph is bipartite as a decision problem.
27. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
28. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
29. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.14 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
30. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
31. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
32. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
33. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
34. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
35. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.15 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
36. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
37. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
38. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
39. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
40. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
41. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.16 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
42. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
43. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
44. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
45. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
46. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
47. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.17 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
48. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
49. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
50. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
51. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
52. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
53. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.18 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
54. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
55. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
56. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
57. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.19 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
58. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
59. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
60. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
61. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
62. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
63. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.20 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
64. Define the problem of deciding whether a given graph is planar as a decision problem.
65. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
66. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
67. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
68. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
69. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.21 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
70. Define the problem of deciding whether a given graph is bipartite as a decision problem.
71. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
72. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
73. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.22 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
74. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
75. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
76. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
77. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
78. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
79. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.23 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
80. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
81. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
82. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
83. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
84. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
85. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.24 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
86. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
87. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
88. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
89. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
90. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
91. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.25 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
92. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
93. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
94. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
95. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
96. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
97. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.26 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
98. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
99. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
100. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
101. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.27 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
102. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
103. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
104. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
105. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
106. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
107. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.28 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
108. Define the problem of deciding whether a given graph is planar as a decision problem.
109. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
110. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
111. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
112. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
113. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.29 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
114. Define the problem of deciding whether a given graph is bipartite as a decision problem.
115. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
116. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
117. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.30 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
118. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
119. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
120. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
121. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
122. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
123. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.31 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
124. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
125. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
126. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
127. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
128. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
129. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.32 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
130. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
131. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
132. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
133. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
134. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
135. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.33 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
136. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
137. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
138. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
139. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
140. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
141. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.34 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
142. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
143. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
144. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
145. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.35 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
146. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
147. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
148. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
149. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
150. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
151. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.36 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
152. Define the problem of deciding whether a given graph is planar as a decision problem.
153. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
154. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
155. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
156. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
157. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.37 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
158. Define the problem of deciding whether a given graph is bipartite as a decision problem.
159. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
160. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
161. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.38 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
162. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
163. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
164. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
165. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
166. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
167. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.39 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
168. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
169. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
170. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
171. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
172. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
173. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.40 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
174. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
175. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
176. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
177. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
178. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
179. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.41 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
180. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
181. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
182. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
183. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
184. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
185. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.42 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
186. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
187. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
188. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
189. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.43 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
190. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
191. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
192. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
193. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
194. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
195. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.44 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
196. Define the problem of deciding whether a given graph is planar as a decision problem.
197. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
198. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
199. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
200. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
201. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.45 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
202. Define the problem of deciding whether a given graph is bipartite as a decision problem.
203. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
204. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
205. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.46 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
206. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
207. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
208. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
209. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
210. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
211. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.47 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
212. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
213. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
214. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
215. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
216. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
217. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.48 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
218. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
219. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
220. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
221. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
222. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
223. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.49 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
224. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
225. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
226. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
227. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
228. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
229. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.50 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
230. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
231. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
232. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
233. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.51 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
234. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
235. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
236. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
237. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
238. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
239. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.52 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
240. Define the problem of deciding whether a given graph is planar as a decision problem.
241. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
242. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
243. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
244. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
245. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.53 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
246. Define the problem of deciding whether a given graph is bipartite as a decision problem.
247. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
248. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
249. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.54 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
250. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
251. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
252. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
253. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
254. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
255. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.55 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
256. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
257. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
258. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
259. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
260. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
261. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.56 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
262. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
263. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
264. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
265. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
266. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
267. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.57 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
268. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
269. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
270. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
271. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
272. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
273. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.58 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
274. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
275. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
276. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
277. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.59 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
278. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
279. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
280. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
281. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
282. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
283. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.60 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
284. Define the problem of deciding whether a given graph is planar as a decision problem.
285. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
286. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
287. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
288. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
289. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.61 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
290. Define the problem of deciding whether a given graph is bipartite as a decision problem.
291. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
292. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
293. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.62 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
294. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
295. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
296. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
297. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
298. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
299. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.63 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
300. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
301. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
302. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
303. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
304. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
305. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.64 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
306. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
307. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
308. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
309. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
310. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
311. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.65 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
312. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
313. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
314. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
315. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
316. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
317. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.66 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
318. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
319. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
320. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
321. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.67 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
322. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
323. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
324. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
325. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
326. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
327. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.68 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
328. Define the problem of deciding whether a given graph is planar as a decision problem.
329. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
330. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
331. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
332. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
333. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.69 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
334. Define the problem of deciding whether a given graph is bipartite as a decision problem.
335. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
336. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
337. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.70 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
338. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
339. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
340. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
341. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
342. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
343. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.71 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
344. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
345. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
346. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
347. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
348. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
349. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.72 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
350. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
351. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
352. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
353. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
354. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
355. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.73 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
356. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
357. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
358. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
359. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
360. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
361. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.74 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
362. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
363. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
364. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
365. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.75 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
366. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
367. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
368. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
369. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
370. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
371. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.76 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
372. Define the problem of deciding whether a given graph is planar as a decision problem.
373. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
374. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
375. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
376. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
377. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.77 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
378. Define the problem of deciding whether a given graph is bipartite as a decision problem.
379. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
380. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
381. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.78 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
382. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
383. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
384. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
385. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
386. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
387. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.79 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
388. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
389. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
390. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
391. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
392. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
393. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.80 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
394. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
395. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
396. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
397. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
398. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
399. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.81 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
400. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
401. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
402. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
403. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
404. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
405. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.82 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
406. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
407. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
408. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
409. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.83 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
410. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
411. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
412. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
413. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
414. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
415. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.84 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
416. Define the problem of deciding whether a given graph is planar as a decision problem.
417. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
418. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
419. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
420. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
421. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.85 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
422. Define the problem of deciding whether a given graph is bipartite as a decision problem.
423. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
424. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
425. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.86 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
426. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
427. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
428. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
429. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
430. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
431. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.87 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
432. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
433. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
434. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
435. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
436. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
437. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.88 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
438. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
439. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
440. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
441. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
442. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
443. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.89 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
444. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
445. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
446. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
447. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
448. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
449. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.90 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
450. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
451. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
452. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
453. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.91 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
454. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
455. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
456. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
457. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
458. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
459. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.92 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
460. Define the problem of deciding whether a given graph is planar as a decision problem.
461. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
462. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
463. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
464. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
465. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.93 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
466. Define the problem of deciding whether a given graph is bipartite as a decision problem.
467. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
468. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
469. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.94 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
470. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
471. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
472. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
473. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
474. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
475. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.95 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
476. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
477. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
478. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
479. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
480. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
481. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.96 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
482. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
483. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
484. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
485. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
486. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
487. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.97 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
488. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
489. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
490. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
491. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
492. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
493. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.98 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
494. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
495. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
496. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
497. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.99 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
498. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
499. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
500. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
501. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
502. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
503. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.100 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
504. Define the problem of deciding whether a given graph is planar as a decision problem.
505. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
506. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
507. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
508. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
509. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.101 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
510. Define the problem of deciding whether a given graph is bipartite as a decision problem.
511. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
512. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
513. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.102 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
514. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
515. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
516. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
517. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
518. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
519. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.103 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
520. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
521. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
522. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
523. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
524. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
525. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.104 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
526. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
527. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
528. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
529. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
530. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
531. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.105 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
532. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
533. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
534. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
535. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
536. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
537. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.106 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
538. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
539. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
540. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
541. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.107 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
542. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
543. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
544. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
545. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
546. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
547. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.108 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
548. Define the problem of deciding whether a given graph is planar as a decision problem.
549. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
550. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
551. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
552. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
553. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.109 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
554. Define the problem of deciding whether a given graph is bipartite as a decision problem.
555. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
556. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
557. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.110 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
558. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
559. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
560. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
561. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
562. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
563. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.111 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
564. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
565. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
566. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
567. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
568. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
569. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.112 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
570. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
571. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
572. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
573. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
574. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
575. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.113 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
576. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
577. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
578. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
579. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
580. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
581. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.114 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
582. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
583. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
584. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
585. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.115 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
586. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
587. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
588. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
589. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
590. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
591. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.116 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
592. Define the problem of deciding whether a given graph is planar as a decision problem.
593. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
594. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
595. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
596. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
597. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.117 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
598. Define the problem of deciding whether a given graph is bipartite as a decision problem.
599. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
600. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
601. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.118 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
602. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
603. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
604. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
605. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
606. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
607. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.119 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
608. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
609. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
610. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
611. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
612. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
613. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.120 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
614. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
615. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
616. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
617. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
618. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
619. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.121 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
620. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
621. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
622. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
623. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
624. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
625. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.122 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
626. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
627. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
628. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
629. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.123 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
630. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
631. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
632. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
633. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
634. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
635. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.124 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
636. Define the problem of deciding whether a given graph is planar as a decision problem.
637. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
638. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
639. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
640. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
641. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.125 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
642. Define the problem of deciding whether a given graph is bipartite as a decision problem.
643. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
644. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
645. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.126 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
646. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
647. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
648. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
649. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
650. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
651. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.127 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
652. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
653. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
654. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
655. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
656. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
657. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.128 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
658. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
659. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
660. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
661. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
662. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
663. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.129 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
664. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
665. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
666. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
667. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
668. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
669. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.130 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
670. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
671. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
672. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
673. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.131 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
674. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
675. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
676. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
677. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
678. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
679. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.132 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
680. Define the problem of deciding whether a given graph is planar as a decision problem.
681. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
682. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
683. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
684. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
685. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.133 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
686. Define the problem of deciding whether a given graph is bipartite as a decision problem.
687. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
688. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
689. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.134 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
690. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
691. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
692. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
693. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
694. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
695. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.135 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
696. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
697. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
698. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
699. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
700. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
701. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.136 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
702. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
703. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
704. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
705. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
706. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
707. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.137 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
708. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
709. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
710. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
711. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
712. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
713. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.138 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
714. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
715. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
716. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
717. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.139 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
718. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
719. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
720. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
721. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
722. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
723. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.140 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
724. Define the problem of deciding whether a given graph is planar as a decision problem.
725. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
726. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
727. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
728. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
729. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.141 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
730. Define the problem of deciding whether a given graph is bipartite as a decision problem.
731. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
732. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
733. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.142 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
734. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
735. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
736. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
737. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
738. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
739. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.143 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
740. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
741. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
742. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
743. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
744. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
745. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.144 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
746. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
747. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
748. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
749. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
750. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
751. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.145 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
752. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
753. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
754. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
755. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
756. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
757. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.146 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
758. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
759. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
760. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
761. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.147 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
762. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
763. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
764. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
765. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
766. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
767. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.148 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
768. Define the problem of deciding whether a given graph is planar as a decision problem.
769. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
770. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
771. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
772. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
773. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.149 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
774. Define the problem of deciding whether a given graph is bipartite as a decision problem.
775. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
776. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
777. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.150 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
778. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
779. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
780. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
781. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
782. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
783. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.151 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
784. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
785. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
786. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
787. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
788. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
789. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.152 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
790. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
791. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
792. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
793. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
794. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
795. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.153 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
796. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
797. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
798. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
799. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
800. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
801. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.154 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
802. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
803. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
804. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
805. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.155 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
806. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
807. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
808. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
809. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
810. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
811. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.156 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
812. Define the problem of deciding whether a given graph is planar as a decision problem.
813. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
814. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
815. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
816. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
817. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.157 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
818. Define the problem of deciding whether a given graph is bipartite as a decision problem.
819. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
820. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
821. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.158 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
822. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
823. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
824. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
825. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
826. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
827. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.159 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
828. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
829. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
830. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
831. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
832. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
833. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.160 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
834. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
835. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
836. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
837. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
838. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
839. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.161 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
840. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
841. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
842. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
843. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
844. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
845. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.162 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
846. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
847. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
848. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
849. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.163 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
850. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
851. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
852. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
853. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
854. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
855. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.164 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
856. Define the problem of deciding whether a given graph is planar as a decision problem.
857. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
858. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
859. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
860. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
861. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.165 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
862. Define the problem of deciding whether a given graph is bipartite as a decision problem.
863. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
864. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
865. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.166 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
866. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
867. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
868. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
869. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
870. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
871. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.167 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
872. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
873. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
874. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
875. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
876. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
877. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.168 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
878. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
879. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
880. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
881. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
882. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
883. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.169 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
884. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
885. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
886. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
887. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
888. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
889. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.170 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
890. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
891. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
892. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
893. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.171 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
894. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
895. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
896. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
897. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
898. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
899. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.172 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
900. Define the problem of deciding whether a given graph is planar as a decision problem.
901. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
902. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
903. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
904. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
905. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.173 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
906. Define the problem of deciding whether a given graph is bipartite as a decision problem.
907. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
908. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
909. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.174 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
910. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
911. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
912. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
913. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
914. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
915. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.175 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
916. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
917. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
918. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
919. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
920. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
921. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.176 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
922. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
923. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
924. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
925. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
926. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
927. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
1.177 PROBLEM 1
Show that the problem of deciding whether a given graph is 3-colorable is NP-complete.
928. Define the problem of deciding whether a given graph is 3-colorable as a decision
problem.
929. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
930. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
931. The problem of deciding whether a given graph is 3-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 3-coloring of 𝐺.
932. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 3-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
933. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 3-colorable. This is trivial
since the problem is the same.
1.178 PROBLEM 2
Show that the problem of deciding whether a given graph is 2-colorable is in P.
934. Define the problem of deciding whether a given graph is 2-colorable as a decision
problem.
935. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
936. The problem of deciding whether a given graph is 2-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 2-coloring of 𝐺.
937. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, color one vertex red and the rest blue.
Check if the coloring is valid.
If the coloring is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
coloring.
1.179 PROBLEM 3
Show that the problem of deciding whether a given graph is 4-colorable is NP-complete.
938. Define the problem of deciding whether a given graph is 4-colorable as a decision
problem.
939. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
940. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
941. The problem of deciding whether a given graph is 4-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 4-coloring of 𝐺.
942. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 4-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
943. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is 4-colorable. Given a graph
𝐺, we add a new vertex 𝑣 and connect it to all vertices in 𝐺. This graph is 4-colorable if
and only if 𝐺 is 3-colorable.
1.180 PROBLEM 4
Show that the problem of deciding whether a given graph is planar is NP-complete.
944. Define the problem of deciding whether a given graph is planar as a decision problem.
945. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
946. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
947. The problem of deciding whether a given graph is planar is a decision problem. Given a
graph 𝐺 = (𝑉,𝐸), we need to decide whether 𝐺 can be drawn in the plane without any
edges crossing.
948. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a planar drawing of 𝐺, check if the drawing is
valid.
If the drawing is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
drawing.
949. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is planar. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is planar if
and only if 𝐺 is 3-colorable.
1.181 PROBLEM 5
Show that the problem of deciding whether a given graph is bipartite is in P.
950. Define the problem of deciding whether a given graph is bipartite as a decision problem.
951. Show that the problem is in P by describing a polynomial-time algorithm that solves the
problem.
Answer:
952. The problem of deciding whether a given graph is bipartite is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 can be partitioned into two sets 𝑉
1
and 𝑉2 such that no edge connects vertices in the same set.
953. A polynomial-time algorithm for solving the problem is as follows:
If 𝐺 has an odd number of vertices, reject.
If 𝐺 has an even number of vertices, partition the vertices into two sets 𝑉
1 and
𝑉2 such that each set has an equal number of vertices.
Check if the partition is valid.
If the partition is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the
partition.
1.182 PROBLEM 6
Show that the problem of deciding whether a given graph is Eulerian is NP-complete.
954. Define the problem of deciding whether a given graph is Eulerian as a decision problem.
955. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
956. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
957. The problem of deciding whether a given graph is Eulerian is a decision problem. Given
a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has an Eulerian tour.
958. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and an Eulerian tour 𝑇 of 𝐺, check if 𝑇 is a valid tour.
If 𝑇 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
tour.
959. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Eulerian. Given a graph 𝐺,
we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in 𝐺.
Then, we add a new edge between each pair of vertices in 𝐺. This graph 𝐺′ is Eulerian if
and only if 𝐺 is 3-colorable.
1.183 PROBLEM 7
Show that the problem of deciding whether a given graph is Hamiltonian is NP-complete.
960. Define the problem of deciding whether a given graph is Hamiltonian as a decision
problem.
961. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
962. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
963. The problem of deciding whether a given graph is Hamiltonian is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether 𝐺 has a Hamiltonian cycle.
964. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a Hamiltonian cycle 𝐶 of 𝐺, check if 𝐶 is a valid
cycle.
If 𝐶 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
cycle.
965. We reduce the known NP-complete problem of deciding whether a given graph is 3-
colorable to the problem of deciding whether a given graph is Hamiltonian. Given a
graph 𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all
vertices in 𝐺. Then, we add a new edge between each pair of vertices in 𝐺. This graph
𝐺′ is Hamiltonian if and only if 𝐺 is 3-colorable.
1.184 PROBLEM 8
Show that the problem of deciding whether a given graph is 5-colorable is NP-complete.
966. Define the problem of deciding whether a given graph is 5-colorable as a decision
problem.
967. Show that the problem is in NP by describing a non-deterministic algorithm that verifies
a solution.
968. Show that the problem is NP-hard by reducing a known NP-complete problem to it.
Answer:
969. The problem of deciding whether a given graph is 5-colorable is a decision problem.
Given a graph 𝐺 = (𝑉, 𝐸), we need to decide whether there exists a 5-coloring of 𝐺.
970. A non-deterministic algorithm for verifying a solution is as follows:
Given a graph 𝐺 = (𝑉, 𝐸) and a 5-coloring 𝑐 of 𝐺, check if 𝑐 is a valid coloring.
If 𝑐 is valid, accept; otherwise, reject.
This algorithm runs in polynomial time because it simply checks the validity of the given
coloring.
971. We reduce the known NP-complete problem of deciding whether a given graph is 4-
colorable to the problem of deciding whether a given graph is 5-colorable. Given a graph
𝐺, we construct a graph 𝐺′ by adding a new vertex 𝑣 and connecting it to all vertices in
𝐺. This graph 𝐺′ is 5-colorable if and only if 𝐺 is 4-colorable.
Students also viewed