Module 2
Module 2
BRUTE FORCE
APPROACHES(conti…)
Exhaustive Search
• a brute-force approach to combinatorial problems.
• It suggests generating each and every element of the problem's
domain, selecting those of them that satisfy all the constraints, and
then finding a desired element.
• Examples for the Exhaustive Search
1.Traveling salesman problem
2. The knapsack problem
Traveling Salesman Problem (TSP)
Problem Statement: Find the shortest tour through a given set of n cities
that visits each city exactly once before returning to the city where it started.
• Modeled by a weighted graph, with the graph's vertices representing the
cities and the edge weights specifying the distances.
• The problem can be stated as the problem of finding the shortest
Hamiltonian circuit of the graph.
• A Hamiltonian circuit is defined as a cycle that passes through all the
vertices of the graph exactly once.
• A Hamiltonian circuit can also be defined as a sequence of 𝑛+1 adjacent
vertices 𝑣𝑖0,𝑣𝑖1,…,𝑣𝑖(𝑛−1),𝑣𝑖0 where the first vertex of the sequence is the
same as the last one, and all the other 𝑛−1 vertices are distinct.
Example problem
Knapsack Problem