You are on page 1of 4

CS607

Assignment no: 1

Date: 14-11-2023

Student Name: Muhammad Sarim

Student Id: Bc200401328

Subject Name: Artificial Intelligence

Questions No. 01 10 Marks


State the situation in which BFS applied and also draw a tree data structure for the
given nodes. You are required to traverse the tree and state the path as per BFS
with height 4. The nodes and height of the tree are given as:
Given Data:
Number of nodes =11
Number of Tree Levels= 3
Nodes Labeling: 1, 2, 7, 8, 3, 6, 9, 12, 4, 5, 10, 11 (Target Node)
You are required to draw a tree for path searching using BFS.
Required:
 Reason for using BFS
 Number of Nodes in Operation
 Levels of Tree
 Path of Tree
 Last Node / Target Node of Tree

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.

Number of Nodes in Operation:


There are 11 nodes in the given tree.
Levels of Tree:
The tree has 3 levels, as mentioned.
Path of Tree (BFS):
Let's traverse the tree using BFS. The levels are numbered starting from 0. We
start from the root (level 0) and move to the next levels in a breadth-first manner.

Level 0: 1
Level 1: 2, 7, 8
Level 2: 3, 6, 9, 12
Level 3: 4, 5, 10, 11 (Target Node)

Last Node / Target Node of Tree:


The last node or target node of the tree is 11.
Questions No. 02
10 Marks
Convert the mentioned below undirected Tree into an undirected Graph.

Undirected Tree:
1

3
2

7
6
4 5

Answer:

You might also like