BFS versus DFS for random targets in ordered trees (2404.05664v1)
Abstract: Consider a search from the root of an ordered tree with $n$ edges to some target node at a fixed distance $\ell$ from that root. We compare the average time complexity of the breadth-first search (BFS) and depth-first search (DFS) algorithms, when the target node is selected uniformly at random among all nodes at level $\ell$ in the ordered trees with $n$ edges. Intuition suggests that BFS should have better average performance when $\ell$ is small, while DFS must have an advantage when $\ell$ is large. But where exactly is the threshold, as a function of $n$, and is it unique? We obtain explicit formulas for the expected number of steps of both BFS and DFS, by using results on the occupation measure of Brownian excursions, as well as a combinatorial proof of an identity related to lattice paths. This allows us to show that there exists a unique constant $\lambda\approx 0.789004$, such that in expectation BFS is asymptotically faster than DFS if and only if $\ell\leq \lambda\sqrt{n}$. Furthermore, we find the asymptotic average time complexity of BFS in the given setting for any class of Galton$\unicode{x2013}$Watson trees, including binary trees and ordered trees. Finally, we introduce the truncated DFS algorithm, which performs better than both BFS and DFS when $\ell$ is known in advance, and we find a formula evaluating the average time complexity of this algorithm.
- David Aldous. The continuum random tree. I. Ann. Probab., 19(1):1–28, 1991.
- David Aldous. The continuum random tree. II. An overview. In Stochastic Analysis (Durham, 1990), volume 167 of London Math. Soc. Lecture Note Ser., pages 23–70. Cambridge Univ. Press, Cambridge, 1991.
- David Aldous. The continuum random tree. III. Ann. Probab., 21(1):248–289, 1993.
- David J. Aldous. Brownian excursion conditioned on its local time. Electron. Comm. Probab., 3:79–90, 1998.
- Proofs That Really Count: The Art of Combinatorial Proof, volume 27 of The Dolciani Mathematical Expositions. Mathematical Association of America, Washington, DC, 2003.
- Miklós Bóna, editor. Handbook of Enumerative Combinatorics. Discrete Mathematics and its Applications (Boca Raton). CRC Press, Boca Raton, FL, 2015.
- Enumerations of ordered trees. Discrete Math., 31(1):9–28, 1980.
- Michael Drmota. Random Trees. SpringerWienNewYork, Vienna, 2009.
- On the profile of random trees. Random Structures Algorithms, 10(4):421–451, 1997.
- The width of Galton-Watson trees conditioned by the size. Discrete Math. Theor. Comput. Sci., 6(2):387–400, 2004.
- Analytical results on the BFS vs. DFS algorithm selection problem. Part I: Tree search. In AI 2015: Advances in Artificial Intelligence, volume 9457 of Lecture Notes in Comput. Sci., pages 157–165. Springer, Cham, 2015.
- Analytic Combinatorics. Cambridge University Press, 2009.
- Ira M. Gessel. Lagrange inversion. J. Combin. Theory Ser. A, 144:212–249, 2016.
- The tutte polynomial of a graph, depth-first search. The Electronic Journal of Combinatorics, pages R9–R9, 1996.
- Depth-first search as a combinatorial correspondence. J. Comb. Theory, Ser. A, 26(3):308–313, 1979.
- Wassily Hoeffding. Probability inequalities for sums of bounded random variables. J. Amer. Statist. Assoc., 58:13–30, 1963.
- Katherine Humphreys. A history and a survey of lattice path enumeration. J. Statist. Plann. Inference, 140(8):2237–2254, 2010.
- Depth-first search performance in a random digraph with geometric outdegree distribution. La Matematica, pages 1–31, 2024.
- Svante Janson. Simply generated trees, conditioned Galton-Watson trees, random allocations and condensation. Probab. Surv., 9:103–252, 2012.
- Olav Kallenberg. Foundations of Modern Probability, volume 99 of Probability Theory and Stochastic Modelling. Springer, Cham, 2021.
- Automated algorithm selection: survey and perspectives. Evol. Comput., 27(1):3–45, 2019.
- Lars Kotthoff. Algorithm selection for combinatorial search problems: a survey. In Data Mining and Constraint Programming, volume 10101 of Lecture Notes in Comput. Sci., pages 149–190. Springer, Cham, 2016.
- Christian Krattenthaler. Lattice path enumeration. In Handbook of Enumerative Combinatorics, Discrete Math. Appl. (Boca Raton), pages 589–678. CRC Press, Boca Raton, FL, 2015.
- Wolfdieter Lang. On polynomials related to derivatives of the generating function of Catalan numbers. Fibonacci Quart., 40(4):299–313, 2002.
- Jean-François Le Gall. Random trees and applications. Probab. Surv., 2:245–311, 2005.
- Paul-A. Meyer. Probability and Potentials. Blaisdell Publishing Co. [Ginn and Co.], Waltham, Mass.-Toronto, Ont.-London, 1966.
- V. V. Petrov. Sums of Independent Random Variables. Ergebnisse der Mathematik und ihrer Grenzgebiete [Results in Mathematics and Related Areas], Band 82. Springer-Verlag, New York-Heidelberg, 1975.
- Artificial Intelligence: A Modern Approach. Pearson, fourth edition, 2021.
- Albert N. Shiryaev. Probability. 1, volume 95 of Graduate Texts in Mathematics. Springer, New York, third edition, 2016.
- The average complexity of depth-first search with backtracking and cutoff. IBM Journal of Research and Development, 30(3):242–258, 1986.
- L. Takács. The distribution of the sojourn time for the Brownian excursion. Methodol. Comput. Appl. Probab., 1(1):7–28, 1999.