Sol - As1 Spring 2024 - CS607
Sol - As1 Spring 2024 - CS607
Assignment # 01 Deadline
th
29 of April 2024
Spring 2024
Question No 01
Marks (10)
Consider the following tree, use simple search algorithm (given on page# 24 of handouts) and apply the
Depth First Search (DFS) strategy. The starting node is 1, and the goal node is 7. You are required to fill
SOLUTION:
1 1 1
2 2, 3 1, 2, 3
3 4, 5, 3 1, 2, 3, 4, 5
4 5, 3 1, 2, 3, 4, 5
5 7, 8, 3 1, 2, 3, 4, 5, 7
6 8, 3 1, 2, 3, 4, 5,7
This is just one possible traversal order for DFS. Depending on how the DFS algorithm is implemented
(e.g., exploring left or right child first), the order of visiting nodes might differ slightly. However, all
Breath First Search (BFS) is a memory hungry search strategy which means it requires a lot of memory
whiling processing a problem even having a reasonable and moderate complexity. It is primarily due to
the branching factor that increase the number of ways to search for the solution (goal/target).
Now, consider that we have a tree width the branching factor of 4 and depth (or height) 12, while each
node requires 16 bytes storage. If the Breath First Search (BFS) is applied to this tree, then calculate the
memory required for this search.
SOLUTION:
1. Total Nodes: We have a tree with branching factor (b) of 4 and depth (d) of 12. The total
number of nodes (N) can be approximated using the formula for a geometric series:
N ≈ (b ^ (d+1)) - 1 / (b - 1)
N ≈ (4 ^ 13) - 1 / 3 ≈ 6143
3. Maximum Memory Usage: BFS needs to keep track of unexpanded nodes at the deepest level
(level 12 in this case).
Memory ≈ Number of nodes at level 12 * Memory per node
Memory ≈ 4 ^ 12 * 16 bytes/node ≈ 262,144 bytes (assuming very large numbers)
Therefore, the maximum memory required by BFS for this tree is approximately 262,144 bytes.