Fall 2022 - CS607 - 1 - SOL
Fall 2022 - CS607 - 1 - SOL
You should consult the recommended books to clarify your concepts as handouts are not
sufficient.
OBJECTIVE
The objective of this assignment is to:
Learn and practice basic concepts of Graphs and trees with traversing techniques.
NOTE
No assignment will be accepted after the due date via email in any case (whether it is the case of
load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the
last hour of deadline. It is recommended to upload solution file at least two days before its closing
date.
If you find any mistake or confusion in assignment (Question statement), please consult with your
instructor before the deadline. After the deadline, no queries will be entertained in this regard.
Consider the case, where we are having option to use either DFS or BFS for
searching target node as a queuing data structure. Consider a puzzle in which
only target node is known and you need to decide that which traversing you
should follow to reach the goal node following a queue. The number of nodes
and height of tree is given as:
Given:
No of nodes =11 (Last level of tree not totally filled (Occupied by Node))
Number of Tree Levels= 4.
Nodes Labeling: R, A, B, C, D, E, F, G, H, I, K (Target Node)
You are required to draw a tree for path searching using BFS .
Solution:
Level 0
R
B Level 1
A
H Level 2
G
D
C
E F I Level 3
Level 4
K
Directed Graph:
TY9KU-YT4RD-QA8SC-VB9KL-TR3ET
S8YVB-N2UYT-RE6VB-YPT6U-YTR7S
BN7MK-UYT8R-S4YVB-N2UYT-YE8TV
B8UYT-RE7CV-BN9TR-D7CBN-H9RES
YN7MK-UYT8R-S4YVB-N2UYT-YE8TV
TY9KU-KT4RD-QA8SC-VB9KL-TR3ET
BN7MK-ZYT8R-Y4YVB-J2UYT-HE8TV
TY9KU-KT4RU-HA8SC-VB9KL-ZR3ET
BN7MK-ZYT8R-S4YVB-J2UYT-YE8TV
B8UYT-RE7CV-BY9TR-D7CBN-H9RES
Directed Graph
E F
R
G C
D
B
UN-directed Graph
E F
R
G C
D
B