Основные понятия
There exists a unique threshold λ ≈ 0.789004 such that BFS is asymptotically faster than DFS in expectation if and only if the target node is at a level less than or equal to λ√n, where n is the number of edges in the ordered tree.
Аннотация
The paper compares the average time complexity of the breadth-first search (BFS) and depth-first search (DFS) algorithms when searching for a random target node at a fixed level in an ordered tree with n edges.
Key highlights:
- Derives an exact formula for the total dfsScore (totalD) across all nodes at a given level in the trees.
- Obtains a summation formula for the total bfsScore (totalB) across all nodes at a given level, and analyzes its asymptotic behavior.
- Proves that there exists a unique threshold λ ≈ 0.789004 such that BFS is asymptotically faster than DFS in expectation if and only if the target node is at a level less than or equal to λ√n.
- Introduces a new "truncated DFS" algorithm that outperforms both BFS and DFS when the target level is known in advance.
- Generalizes the results on totalB to arbitrary Galton-Watson trees.
Статистика
n(n + 1)/2
2ℓ + 1
2n + 1
n - ℓ
4n / √πne^(-ℓ^2/n) + O(1/n^(3/2))
2ℓ + 1
2n + 1
n - ℓ
Цитаты
"Intuition suggests that BFS should have better average performance when ℓ is small, while DFS must have an advantage when ℓ is large. But where exactly is the threshold, as a function of n, and is it unique?"
"There exists a unique constant λ ≈ 0.789004, such that in expectation BFS is asymptotically faster than DFS if and only if ℓ ≤ λ√n."