Depth-First Search Using \(O(n)\) Bits

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8889)


We provide algorithms performing Depth-First Search (DFS) on a directed or undirected graph with \(n\) vertices and \(m\) edges using only \(O(n)\) bits. One algorithm uses \(O(n)\) bits and runs in \(O(m \log n)\) time. Another algorithm uses \(n+o(n)\) bits and runs in polynomial time. Furthermore, we show that DFS on a directed acyclic graph can be done in space \(n/2^{\varOmega (\sqrt{\log n})}\) and in polynomial time, and we also give a simple linear-time \(O(\log n)\)-space algorithm for the depth-first traversal of an undirected tree. Finally, we also show that for a graph having an \(O(1)\)-size feedback set, DFS can be done in \(O(\log n)\) space. Our algorithms are based on the analysis of properties of DFS and applications of the \(s\)-\(t\) connectivity algorithms due to Reingold and Barnes et al., both of which run in sublinear space.


Undirected Graph Black Vertex White Vertex Adjacency List White Neighbor 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aggarwal, A., Anderson, R.: A Random NC Algorithm for Depth-First Search. Combinatorica 8(1), 1–12 (1988)CrossRefzbMATHMathSciNetGoogle Scholar
  2. 2.
    Anderson, R., Mayr, E.: Parallelism and the Maximal Path Problem. Information Processing Letters 24(2), 121–126 (1987)CrossRefzbMATHMathSciNetGoogle Scholar
  3. 3.
    Asano, T., Elmasry, A., Katajainen, J.: Priority Queues and Sorting for Read-Only Data. In: Chan, T.-H.H., Lau, L.C., Trevisan, L. (eds.) TAMC 2013. LNCS, vol. 7876, pp. 32–41. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  4. 4.
    Asano, T., Kirkpatrick, D.: Time-Space Tradeoffs for All-Nearest-Larger-Neighbors Problems. In: Dehne, F., Solis-Oba, R., Sack, J.-R. (eds.) WADS 2013. LNCS, vol. 8037, pp. 61–72. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  5. 5.
    Asano, T., Kirkpatrick, D., Nakagawa, K., Watanabe, O.: \(\tilde{O}(\sqrt{n})\)-Space and Polynomial-time Algorithm for the Planar Directed Graph Reachability Problem. ECCC Report 71 (2014); also. In: Ésik, Z., Csuhaj-Varjú, E., Dietzfelbinger, M. (eds.) MFCS 2014, Part II. LNCS, vol. 8635, pp. 45–56. Springer, Heidelberg (2014)Google Scholar
  6. 6.
    Barnes, G., Buss, J., Ruzzo, W., Schieber, B.: A Sublinear Space, Polynomial Time Algorithm for Directed \(s\)-\(t\) Connectivity. SIAM Journal of Computing 27(5), 1273–1282 (1998)CrossRefzbMATHMathSciNetGoogle Scholar
  7. 7.
    Elberfeld, M. Jakoby, A., Tantau, T.: Logspace Versions of the Theorems of Bodlaender and Courcelle. In: Proceedings of the 51st Annual IEEE Symposium on Foundations of Computer Science (FOCS 2010), pp. 143–152 (2010)Google Scholar
  8. 8.
    Elberfeld, M., Kawarabayashi, K.: Embedding and Canonizing Graphs of Bounded Genus in Logspace. In: Proceedings of the 46th Annual ACM Symposium on the Theory of Computing (STOC 2014), pp. 383–392 (2014)Google Scholar
  9. 9.
    Imai, T.: Polynomial-Time Memory Constrained Shortest Path Algorithms for Directed Graphs. In: Proceedings of the 12th Forum on Information Technology, vol. 1, pp. 9–16 (2013) (in Japanese)Google Scholar
  10. 10.
    Imai, T., Nakagawa, K., Pavan, A., Vinodchandran, N., Watanabe, O.: An \(O(n^{1/2+\epsilon })\)-Space and Polynomial-Time Algorithm for Directed Planar Reachability. In: Proceedings of 2013 IEEE Conference on Computational Complexity, pp. 277–286 (2013)Google Scholar
  11. 11.
    Konagaya, M., Asano, T.: Reporting All Segment Intersections Using an Arbitrary Sized Work Space. IEICE Transactions 96-A(6), 1066–1071 (2013)Google Scholar
  12. 12.
    Papadimitriou, C.: Computational complexity. Addison-Wesley (1994)Google Scholar
  13. 13.
    Reif, J.: Depth-First Search Is Inherently Sequential. Information Processing Letters 20(5), 229–234 (1985)CrossRefzbMATHMathSciNetGoogle Scholar
  14. 14.
    Reingold, O.: Undirected Connectivity in Log-Space. Journal of the ACM 55(4), 17:1–17:24 (2008)Google Scholar
  15. 15.
    Tarjan, R.: Depth-First Search and Linear Graph Algorithms. SIAM Journal on Computing 1(2), 146–160 (1972)CrossRefzbMATHMathSciNetGoogle Scholar
  16. 16.
    de la Tore, P., Kruskal, C.: Fast Parallel Algorithms for Lexicographic Search and Path-Algebra Problems. Journal of Algorithms 19, 1–24 (1995)CrossRefMathSciNetGoogle Scholar
  17. 17.
    de la Tore, P., Kruskal, C.: Polynomially Improved Efficiency for Fast Parallel Single-Source Lexicographic Depth-First Search, Breadth-First Search, and Topological-First Search. Theory of Computing Systems 34, 275–298 (2001)CrossRefMathSciNetGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  1. 1.JAISTNomiJapan
  2. 2.Nagoya Institute of TechnologyNagoyaJapan
  3. 3.Yokohama City UniversityYokohamaJapan
  4. 4.Kyushu UniversityFukuokaJapan
  5. 5.RWTH Aachen UniversityAachenGermany
  6. 6.University of Electro-CommunicationsChofuJapan

Personalised recommendations