You are on page 1of 3

What is Brute force approach?

Brute force is a straightforward approach to solving a problem, usually directly


based on the problem statement and definitions of the concepts involved.

Graph Search:- BFS and DFS


1. BFS and DFS works on both directed as well as on undirected graphs.
2. BFS and DFS traversal result in acyclic graph.
3. BFS traversal and DFS traversal on the same graph do not give the same
order of vertices as output i.e. they generally result in different acyclic
graphs.
4. Source vertex is given in case of BFS but no Source vertex is given in case of
DFS.

Important Note:- Graph can be directed graph where the edges are
directed or in ordered pair or graph can be undirected where the order of
edges is immaterial.

By default, the term graph will mean an undirected graph.

1
Main facts about depth-first search (DFS)
and breadth-first search (BFS)

2
For example, a graph G with V vertices is a tree if
and
only if it satisfies any of the following five
conditions:
G has V1 edges and no cycles.
G has V1 edges and is connected.
G is connected, but removing any edge
disconnects it.
G is acyclic, but adding any edge creates a cycle.
Exactly one simple path connects each pair of
vertices in G.

You might also like