Professional Documents
Culture Documents
cs701 - Assignment 1
cs701 - Assignment 1
Assignment no: 1
Date: 14-11-2023
Answer:
Reason for using BFS:
BFS (Breadth-First Search) is used when you need to investigate all of the nodes
at the current level of a tree or graph before going on to the next level. It is very
helpful in determining the shortest path between two nodes in an unweighted
network or tree. In this scenario, BFS is used to traverse the tree level by level,
beginning at the root, which is the best technique when looking for the shortest
path.
Level 0: 1
Level 1: 2, 7, 8
Level 2: 3, 6, 9, 12
Level 3: 4, 5, 10, 11 (Target Node)
Undirected Tree:
1
3
2
7
6
4 5
Answer: