The value of is _____________
View worked solution
Answer: 1 : 1
Let the 7 nodes of the complete binary tree be represented as follows, where 1 is the root:
1
/ \
2 3
/ \ / \
4 5 6 7
1. Breadth-First Search (BFS):
BFS visits the nodes level-by-level from left to right. The first 3 elements visited are 1, 2, and 3.
Therefore, the set .
2. Depth-First Search (DFS):
DFS starting from the root visits a child and then goes deeper to a grandchild before backtracking. Depending on whether we traverse left-first or right-first:
- If left-first: The first 3 elements visited are 1, 2, and then either 4 or 5. Thus, or .
- If right-first: The first 3 elements visited are 1, 3, and then either 6 or 7. Thus, or .
3. Calculating :
- If , then , so .
- If , then , so .
In all possible DFS traversals, the cardinality of the set difference is exactly 1.
Free practice · Your answers on this page are not saved.
