21BCE9125 DAA Assignment-8
21BCE9125 DAA Assignment-8
ASSIGNMENT - 8
SLOT: L31+L32
SUBMITTED BY
SUBMITTED TO
return minPath;
}
if (dp[start][mask] != -1)
return dp[start][mask];
Output:
2. Write a program for solving graph colouring problems using
backtracking.
Aim:
The aim of this problem is to assign colors to vertices of a graph in such a way
that no two adjacent vertices have the same color using the minimum number
of colors.
Theory:
Graph coloring is a fundamental problem in graph theory. It involves assigning
colors to the vertices of a graph in such a way that no two adjacent vertices share
the same color. Backtracking is commonly used to solve this problem.
Code:
import java.util.Arrays;
Output:
3. Write a program to find the Hamiltonian Circuit in a given graph.
Aim:
The aim of this problem is to find a closed loop in a graph that visits every vertex
exactly once.
Theory:
A Hamiltonian Circuit is a closed loop that visits every vertex exactly once in a
graph. Finding a Hamiltonian Circuit is NP-complete, meaning that there's no
known efficient algorithm to solve it for all graphs. Backtracking is often used to
find Hamiltonian Circuits in graphs.
Code:
import java.util.ArrayList;
return true;
}
Output: