DAA Lab: Matrix Multiplication & Algorithms
DAA Lab: Matrix Multiplication & Algorithms
Aim:
To implement recursive and non-recursive algorithm and study the order of growth from
log2nto n! .
(Tower of Hanoi)Algorithm:
Step 1 : Start with a function called tower_of_hanoi(n, from_rod, to_rod, aux_rod) which
takes 3 rods
and the number of disks as input.
Step 2 : If the number of disks is 1, move the disk from the from_rod to the to_rod.
Step 3 : Else, move the top n-1 disks from the from_rod to the aux_rod using the to_rod as
the auxiliaryrod.
Step 4 : move the nth disk from the from_rod to the to_rod
Step 5 : move the n-1 disks from the aux_rod to the to_rod using the from_rod as the
auxiliary rod.
2
Program:
# Python 3 program to
# find log(n) using
Recursiondef Log2n(n):
# Driver
coden = 32
print(Log2n(n))
n=3
Output:
5
3
(B) Non-Recursive Algorithm
Step 1: Start with a function called sum_of_elements(arr) which takes an array as input.
in the array
the result
Program:
def
sum_of_elements(arr
):result = 0
for element in arr:
result += element
return result
arr = [1,2,3,4,5]
print(sum_of_elements(arr))
output:
15
4
Performance 25
Record 15
Viva 10
Total 50
(a)Result :
Thus the Recursive algorithm and study the order of growth from log2n to n! has
been implemented output verified and
(b) Result :
Thus the Non-recursive algorithm and study the order of growth from log2n to n! has
implemented successfully and output was verified
5
DATE: DIVIDE AND CONQUER - STRASSEN’S
MATRIX MULTIPLICATION
[Link]
Aim:
To implement Divide and Conquer algorithm using Strassen’s Matrix Multiplication.
Algorithm:
Step 1: Start with a function called strassen(A, B) which takes two matrices A and B as
input.
Step 2: Divide each matrix into 4 sub-matrices (A11, A12, A21, A22, B11, B12, B21, B22)
Step 6: Combine the 4 matrices (C11, C12, C21, C22) to form the result matrix C.
6
Program:
# Python program to find the resultant
# product matrix for a given pair of matrices
# using Divide and Conquer Approach
ROW_1 = 4
COL_1 = 4
ROW_2 = 4
COL_2 = 4
print()
print()
7
#Function to initialize matrix with zeros
def initWithZeros(a, r, c):
for i in range(r):
for j in range(c):
a[i][j] = 0
if (col_1 != row_2):
print("\nError: The number of columns in Matrix A must be equal to the number of
rows in Matrix B\n")
return 0
if (col_1 == 1):
else:
split_index = col_1 // 2
8
a00 = [[0 for x in range(split_index)] for y in range(split_index)]
a01 = [[0 for x in range(split_index)] for y in range(split_index)]
a10 = [[0 for x in range(split_index)] for y in range(split_index)]
a11 = [[0 for x in range(split_index)] for y in range(split_index)]
b00 = [[0 for x in range(split_index)] for y in range(split_index)]
b01 = [[0 for x in range(split_index)] for y in range(split_index)]
b10 = [[0 for x in range(split_index)] for y in range(split_index)]
b11 = [[0 for x in range(split_index)] for y in range(split_index)]
for i in range(split_index):
for j in range(split_index):
a00[i][j] = matrix_A[i][j]
a01[i][j] = matrix_A[i][j + split_index]
a10[i][j] = matrix_A[split_index + i][j]
a11[i][j] = matrix_A[i + split_index][j + split_index]
b00[i][j] = matrix_B[i][j]
b01[i][j] = matrix_B[i][j + split_index]
b10[i][j] = matrix_B[split_index + i][j]
b11[i][j] = matrix_B[i + split_index][j + split_index]
add_matrix(multiply_matrix(a00, b00),multiply_matrix(a01,
b10),result_matrix_00, split_index)
add_matrix(multiply_matrix(a00, b01),multiply_matrix(a01,
b11),result_matrix_01, split_index)
add_matrix(multiply_matrix(a10, b00),multiply_matrix(a11,
b10),result_matrix_10, split_index)
add_matrix(multiply_matrix(a10, b01),multiply_matrix(a11,
b11),result_matrix_11, split_index)
for i in range(split_index):
for j in range(split_index):
result_matrix[i][j] = result_matrix_00[i][j]
result_matrix[i][j + split_index] = result_matrix_01[i][j]
result_matrix[split_index + i][j] = result_matrix_10[i][j]
result_matrix[i + split_index][j + split_index] = result_matrix_11[i][j]
return result_matrix
# Driver Code
matrix_A = [ [1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[2, 2, 2, 2] ]
print("Array A =>")
printMat(matrix_A,4,4)
9
matrix_B = [ [1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[2, 2, 2, 2] ]
print("Array B =>")
printMat(matrix_B,4,4)
Output:
Array A =>
1111
2222
3333
2222
Array B =>
1111
2222
3333
2222
10
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Divide and Conquer algorithm using Strassen’s Matrix Multiplication was
executed successfully and output was verified
11
12
DATE:
DECREASE AND CONQUER –
[Link] TOPOLOGICAL SORTING
Aim:
To implement Decrease and Conquer approach to topological sorting.
Algorithm:
Step 1: Start with a function called topological_sort(graph) which takes a directed graph as
input.
Step 2: Initialize an empty stack and a list to store the visited nodes.
Step 3: For each node in the graph, if it has not been visited, call the function visit(node)
recursively.
Step 4: In the visit(node) function, mark the current node as visited, then recursively
call the visit function for each of its neighbors (nodes it has an edge pointing to) which
have notbeen visited yet.
Step 5: After all the neighbors of the current node have been visited, push the current node
tothe stack.
Step 6: Once the visit function has been called for all nodes in the graph, the stack
willcontain the nodes in topological order.
Program:
class Graph:
def init (self, vertices):
[Link] = defaultdict(list) # dictionary containing adjacency List
self.V = vertices # No. of vertices
13
# function to add an edge to graph
def addEdge(self, u, v):
[Link][u].append(v)
14
# Driver Code
if __name == ' main ':
g = Graph(6)
[Link](5, 2)
[Link](5, 0)
[Link](4, 0)
[Link](4, 1)
[Link](2, 3)
[Link](3, 1)
# Function Call
[Link]()
Output:-
15
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Decrease and Conquer approach to topological sorting was executed successfully
andoutput was verified.
16
17
DATE:
TRANSFORM AND CONQUER - HEAP SORT
[Link]
Aim:
To implement Transform and Conquer using Heap Sort.
Algorithm:
Step 1: Create a dictionary to store the indegree of each vertex and initialize it to 0 for all
vertices.
Step 3: Traverse the edges of the graph and for each edge (u, v), increment the indegree of
vertex v in theindegree dictionary.
Step 4: Create a priority queue (heap) and insert all the vertices with indegree 0.
Step 6: Pop the vertex with the highest priority from the heap.
Step 8: For each neighbor of the popped vertex, decrement its indegree.
Step 10: If the result list contains all the vertices, return the list as the topological ordering,
otherwise, return None as the graph has a cycle
18
Program:
r = 2 * i + 2 # right = 2*i + 2
def heapSort(arr):
N = len(arr)
# Build a maxheap.
for i in range(N//2 - 1, -1, -1):
heapify(arr, N, i)
19
# Driver's code
if __name == ' main ':
arr = [12, 11, 13, 5, 6, 7]
# Function call
heapSort(arr)
N = len(arr)
Output :-
Sorted array is
5 6 7 11 12 13
20
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Transform and Conquer using Heap Sort was implemented and output was verified
successfully.
21
22
DATE:
[Link] DYNAMIC PROGRAMMING - COIN CHANGING
Aim:
To implement Dynamic Programming using Coin Changing Problem
ProblemAlgorithm:
Step 2: Create a list dp of length (amount + 1) and initialize it with the value of infinity.
Step 3: Set dp[0] = 0, as the minimum number of coins needed to make 0 amount is 0.
Step 4: Iterate through the range 1 to amount+1 and for each i, iterate through the coin
denominations.
Step 5: For each coin denomination, check if the coin value is less than or equal to i,
if true then check ifdp[i - coin value] + 1 is less than dp[i], if true then update dp[i] =
dp[i -coin value] + 1.
Step 6: Return dp[amount] as the minimum number of coins needed to make the
targetamount.
23
Program:
# Recursive Python3 program for
# coin change problem.
Output
5
24
Performance 25
Record 15
Viva 10
Total 50
RESULT:
Aim:
To implement Dynamic Programming using Warshall’s algorithm
AlgorithmWarshall’s
Algorithm:
Step 2: Create a matrix dist of the same size as the input graph, and initialize it with the
graph itself.
Step 4: Nest two more loops, one to iterate through the range of the number of rows, i and
another to iteratethrough the range of the number of columns, j.
Step 5: If dist[i][j] > dist[i][k] + dist[k][j], then update dist[i][j] = dist[i][k] + dist[k][j].
26
Program:
def floydWarshall(graph):
27
vertices in the set
{0, 1, 2, .. k-1} as intermediate vertices.
----> After the end of a
iteration, vertex no. k is
added to the set of intermediate
vertices and the
set becomes {0, 1, 2, .. k}
"""
for k in range(V):
28
# Driver's code
if __name == " main ":
"""
10
(0)------->(3)
| /|\
5| |
| |1
\|/ |
(1)------->(2)
3 """
graph = [[0, 5, INF, 10],
[INF, 0, 3, INF],
[INF, INF, 0, 1],
[INF, INF, INF, 0]
]
# Function call
floydWarshall(graph)
Output:
Following matrix shows the shortest distancesbetween every pair of vertices
0 5 8 9
INF 0 3 4
INF INF 0 1
INF INF INF 0
29
Performance 25
Record 15
Viva 10
Total 50
RESULT:
Thus the Dynamic Programming using Coin Changing Problem, Warshall’s algorithms
30
DATE:
[Link] DYNAMIC PROGRAMMING - Floyd’s Algorithm
Aim:
Floyd’s Algorithm:
Step 2: Create a matrix dist of the same size as the input graph, and initialize it with the
graphitself.
Step 4: Nest two more loops, one to iterate through the range of the number of rows, i and
another to iterate through the range of the number of columns, j.
Step 5: If dist[i][j] > dist[i][k] + dist[k][j], then update dist[i][j] = dist[i][k] + dist[k][j].
31
Program
# python code for the above approach
class Solution:
for u, v, wt in grid:
# Driver code
If __name__==’ __main__”
V=6
grid = [[0, 1, 2], [0, 3, 5], [0, 4, 3], [1, 0, 3], [1, 5, 6], [1, 2, 2], [1, 3, 2],
[2, 5, 1], [2, 3, 1], [3, 4, 1], [4, 3, 2]]
s1 = Solution()
# Function call
s1.shortest_paths(grid, V)
32
Output:-
0 to 0 ---> 0
0 to 1 ---> 2
0 to 2 ---> 4
0 to 3 ---> 4
0 to 4 ---> 3
0 to 5 ---> 5
Performance 25
Record 15
Viva 10
Total 50
RESULT:
33
DATE:
[Link] DYNAMIC PROGRAMMING – Knapsack Problem
Aim:
To implement Dynamic Programming using Knapsack Problem.
Algorithm:
Step 3: Iterate through the range 1 to number of items + 1, i, and for each i, iterate
through the range 0 toweight_limit + 1, w.
Step 4: If the weight of the i-th item is less than or equal to w, then check if dp[i-1][w] is
greater than dp[i- 1][w-weight of i-th item] + value of i-th item. If true then update dp[i][w]
= dp[i-1][w-weight of i-th item] +value of i-th item
34
Program:
# Base Case
if n == 0 or W == 0:
return 0
35
else:
# Driver Code
if __name == ' main ':
profit = [60, 100, 120]
weight = [10, 20, 30]
W = 50
n = len(profit)
print knapSack(W, weight, profit, n)
Performance 25
Record 15
Viva 10
Total 50
RESULT:
36
37
DATE: GREEDY TECHNIQUE - DIJKSTRA’S
ALGORITHM,
[Link]
Aim:
(A)Dijkstra’s Algorithm:
Step 1: Define a function Dijkstra(graph, start) that takes in a weighted graph represented
as an adjacency list and a starting vertex as input.
Step 2: Create an empty priority queue (min heap) and a dictionary to store the shortest
distance from the start vertex to each vertex.
Step 3: Initialize the dictionary with a distance of infinity for all vertices except the
start vertex, which should have a distance of 0.
Step 4: Insert the start vertex into the priority queue with a distance of 0.
Step 6: Pop the vertex with the smallest distance from the priority queue.
Step 8: If the distance to the neighbor can be shortened by going through the popped
vertex, update the distance in the dictionary and insert the neighbor into the priority
queue.
Step 9: Return the dictionary containing the shortest distance from the start vertex to
each vertex as the result.
Program:
38
# Library for INT_MAX
import sys
class Graph():
return min_index
[Link](dist)
# Driver's code
if __name == " main ":
g = Graph(9)
[Link] = [[0, 4, 0, 0, 0, 0, 0, 8, 0],
[4, 0, 8, 0, 0, 0, 0, 11, 0],
[0, 8, 0, 7, 0, 4, 0, 0, 2],
[0, 0, 7, 0, 9, 14, 0, 0, 0],
[0, 0, 0, 9, 0, 10, 0, 0, 0],
[0, 0, 4, 14, 10, 0, 2, 0, 0],
[0, 0, 0, 0, 0, 2, 0, 1, 6],
[8, 11, 0, 0, 0, 0, 1, 0, 7],
[0, 0, 2, 0, 0, 0, 6, 7, 0]
]
[Link](0)
40
Output:
Performance 25
Record 15
Viva 10
Total 50
RESULT:
41
42
43
DATE: GREEDY TECHNIQUE –HUFFMANN
TREE AND CODES
[Link]
Aim:
Step 1: Create a list of tuples for each character in the text, where each tuple
containsthe character, its frequency, and a unique identifier.
Step 3: Create a leaf node for each tuple and add it to a priority queue (min heap) based on
the frequency.
Step 4: While the priority queue has more than one node: Step 5: Remove the two nodes
with the smallest frequency from the priority queue. Step 6: Create a new internal node
witha frequency equal to the sum of the frequencies of the removed nodes. Step 7: Make
the removed nodes left and right children of the new internal node. Step 8: Insert the
new internal node into the priority queue.
Step 9: The remaining node in the priority queue is the root of the Huffman tree.
Step 10: Traverse the Huffman tree and assign 0 to the left child and 1 to the right
childat each internal node.
Step 11: For each leaf node, the code is the path from the root to the leaf, where left child is
represented by0 and right child is represented by 1.
Step 12: Store the codes for each character in a dictionary for easy lookup and decoding.
44
Program:
class node:
def init (self, freq, symbol, left=None, right=None):
# frequency of symbol
[Link] = freq
45
def printNodes(node, val=''):
# frequency of characters
freq = [5, 9, 12, 13, 16, 45]
46
# sort all the nodes in ascending order
# based on their frequency
left = [Link](nodes)
right = [Link](nodes)
[Link](nodes, newNode)
Output:
f -> 0
c -> 100
d -> 101
a -> 1100
b -> 1101
e -> 111
47
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Greedy Technique using Huffmann Tree and Codes has been implemented and
output was verified successfully.
48
49
DATE: ITERATIVE IMPROVEMENT - SIMPLEX
METHOD
[Link]
Aim:
Algorithm:
Step 1: Write the problem in standard form, where the objective function is to be
maximized or minimized,and the constraints are in the form of inequalities or
equalities.
Step 2: Create the initial simplex tableau by writing the constraints as equations in
matrix form, andincluding the objective function as the last row.
Step 3: Check if the solution is feasible by checking if all the values in the right-hand side
column are non-negative. If not, the problem is infeasible.
Step 4: Choose the pivot column, which is the column with the most negative
coefficient in the last row(objective function row).
Step 5: Choose the pivot row, which is the row with the smallest positive ratio of the
right-hand side columnand the pivot column.
Step 6: Pivot on the chosen pivot element and perform row operations to obtain a new
tableau.
Step 7: Check if the objective function value has improved. If not, go to step 4. If it has,
check if there are any negative values in the last row (objective function row) other than
theright-hand side column. If not, thesolution is optimal. If there are, go to step 4.
Step 8: The optimal solution can be read off the right-hand side column of the final
tableau, where thevariables are the basic variables and the values are the
correspondingoptimal values.
50
Program:
import numpy as np
from fractions import Fraction # so that numbers are not displayed in decimal.
# inputs
51
# when optimality reached it will be made 1
reached = 0
itr = 1
unbounded = 0
alternate = 0
while reached == 0:
b_var = table[:, 0]
# checking for alternate solution
while i<len(A[0]):
j=0
present = 0
while j<len(b_var):
if int(b_var[j]) == i:
present = 1
break;
j+= 1
if present == 0:
if rel_prof[i] == 0:
alternate = 1
print("Case of Alternate found")
# print(i, end =" ")
i+= 1
print()
flag = 0
52
for profit in rel_prof:
if profit>0:
flag = 1
break
# if all relative profits <= 0
if flag == 0:
print("All profits are <= 0, optimality reached")
reached = 1
break
pivot = table[r][3 + k]
print("pivot element: ", end =" ")
print(Fraction(pivot).limit_denominator(100))
print()
print()
itr+= 1
print()
print("***************************************************************")
if unbounded == 1:
print("UNBOUNDED LPP")
exit()
if alternate == 1:
print("ALTERNATE Solution")
print("optimal table:")
print("B \tCB \tXB \ty1 \ty2 \ty3 \ty4")
for row in table:
for el in row:
print(Fraction(str(el)).limit_denominator(100), end ='\t')
print()
print()
print("value of Z at optimality: ", end =" ")
basis = []
i=0
sum = 0
while i<len(table):
sum += c[int(table[i][0])]*table[i][2]
temp = "x"+str(int(table[i][0])+1)
[Link](temp)
i+= 1
# if MIN problem make z negative
if MIN == 1:
print(-Fraction(str(sum)).limit_denominator(100))
else:
print(Fraction(str(sum)).limit_denominator(100))
print("Final Basis: ", end =" ")
print(basis)
54
print("Simplex Finished...")
print()
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Iterative Improvement using Simplex Method has been implemented and output
verified successfully
55
56
DATE:
BACKTRACKING - N-QUEEN PROBLEM,
[Link]
Aim:
To implement Backtracking using N-Queen Problem .
Step 1: Define a function solveNQueens(n) that takes in the number of queens as input.
Step 2: Initialize a 2D list of size nxn to represent the chessboard and set all elements to 0.
Step 3: Define a recursive function backtrack(board, col) that takes in the current chessboard
and the currentcolumn as input.
Step 4: If the current column is equal to the number of queens, then a valid solution
hasbeen found, add itto the result list.
Step 5: Iterate through the rows of the current column, and for each row, check if it is
safe to place a queenin that position by checking if it is not in the same row, column, or
diagonalas any other previously placedqueens.
Step 6: If the position is safe, place a queen in that position, mark the position in the
chessboard as 1, andcall the backtrack function with the updated chessboard and the
nextcolumn.
Step 7: After the recursive call, remove the queen from the current position
and mark it as 0 in thechessboard.
Step 8: Call the backtrack function with the initial chessboard and the first column
Program:
global N
N=4
57
def printSolution(board):
for i in range(N):
for j in range(N):
if board[i][j] == 1:
print("Q",end=" ")
else:
print(".",end=" ")
print()
return True
if solveNQUtil(board, 0) == False:
print("Solution does not exist")
return False
printSolution(board)
return True
# Driver Code
if __name == ' main ':
solveNQ()
59
output:-
..Q.
Q...
...Q
.Q..
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Backtracking using N-Queen Problem has beenimplemented and output was
verified successfully.
60
DATE:
BACKTRACKING -SUBSET SUMPROBLEM
[Link]
Aim:
Step 2: Initialize an empty list to store the subsets that add up to the target sum.
Step 4: If the current sum is equal to the target sum, add the subset to the result list.
Step 5: If the current sum is greater than the target sum, return without taking any
furtheraction.
Step 6: Iterate through the remaining elements in the numbers array, starting from the
current index.
Step 7: For each element, add it to the current subset, and call the backtrack function
with the updatedsubset and current sum.
Step 8: After the recursive call, remove the last element from the current subset.
Step 9: Call the backtrack function with the initial parameters, the first index of the numbers
array, an emptysubset, and a current sum of 0.
Step 10: Return the list of subsets that add up to the target sum.
61
Program:
if (sum == 0):
return 1
if (n <= 0):
return 0
else:
63
Driver Code
if __name == ' main ':
n=5
a = [1, 5, 3, 7, 4]
sum = 12
if (subsetSum(a, n, sum)):
print("YES")
else:
print("NO")
Output:
yes
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Backtracking using Subset Sum Problem has beenimplemented and output
was verified successfully.
64
65
DATE:
Branch and Bound - Assignment Problem
[Link]
Aim:
Step 3: Create a lower bound for the problem by finding the minimum value of each
row and column in thecost matrix and subtracting the minimum value from each
element in thecorresponding row or column.
Repeat this process until all the rows and columns have been processed.
Step 4: Use the lower bound as a threshold for the branch and bound algorithm. At
each branch, check if thelower bound is less than or equal to the current best
solution. If it is, continue branching. If not, prune the branch.
Step 5: At each leaf node of the branch and bound tree, check if a complete feasible
solutionhas been [Link] it has, check if it is better than the current best solution. If it is,
update the best solution.
Step 6: Repeat steps 4 and 5 until the entire branch and bound tree has been searched.
Step 7: The final solution will be the best solution found during the branch and bound
search.
Program:
// contains Job ID
int jobID;
node->parent = parent;
node->workerID = x;
node->jobID = y;
return node;
}
// store cost
min = costMatrix[i][j];
}
}
return cost;
}
// print Assignments
68
void printAssignments(Node *min)
{
if(min->parent==NULL)
return;
printAssignments(min->parent);
cout << "Assign Worker " << char(min->workerID + 'A')
<< " to Job " << min->jobID << endl;
// Driver code
int main()
{
// x-coordinate represents a Worker
// y-coordinate represents a Job
int costMatrix[N][N] =
{
{9, 2, 7, 8},
{6, 4, 3, 7},
{5, 8, 1, 8},
{7, 6, 9, 4}
};
/* int costMatrix[N][N] =
{
{82, 83, 69, 92},
{77, 37, 49, 92},
{11, 69, 5, 86},
{ 8, 9, 98, 23}
};
*/
70
/* int costMatrix[N][N] =
{
{2500, 4000, 3500},
{4000, 6000, 3500},
{2000, 4000, 2500}
};*/
/*int costMatrix[N][N] =
{
{90, 75, 75, 80},
{30, 85, 55, 65},
{125, 95, 90, 105},
{45, 110, 95, 115}
};*/
return 0;
}
71
Output :
Assign Worker A to Job 1
Assign Worker B to Job 0
Assign Worker C to Job 2
Assign Worker D to Job 3
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Branch and Bound in Assignment Problem has been implemented and output
was verified successfully.
72
DATE:
Branch and Bound Traveling Salesman Problem
[Link]`
Aim:
Step 1: Formulate the problem as a TSP, where there is a set of cities and the goal is
tofind the shortestpossible route that visits each city exactly once and returns to the
starting city.
Step 3: Create a lower bound for the problem by using a method such as a Minimum
Spanning Tree (MST)algorithm to find the shortest possible route that visits each
city at least once.
Step 4: Use the lower bound as a threshold for the branch and bound algorithm. At
eachbranch, check if thelower bound is less than or equal to the current best solution.
If it is, continue branching. If not, prune the branch.
Step 5: At each leaf node of the branch and bound tree, check if a complete feasible
solutionhas been [Link] it has, check if it is better than the current best solution. If it is,
update the best solution.
Step 6: Repeat steps 4 and 5 until the entire branch and bound tree has been searched.
Step 7: The final solution will be the best solution found during the branch and bound
search, which will bethe shortest possible route that visits each city exactly once and
returnsto the starting city.
Program:
next_permutation=permutations(vertex)
for i in next_permutation:
# update minimum
min_path = min(min_path, current_pathweight)
return min_path
# Driver Code
if __name == " main ":
74
Performance 25
Record 15
Viva 10
Total 50
Result:
Thus the Branch and Bound in Traveling Salesman Problem has been implemented and
output was verified successfully.
75