>RunTimeFix
BookStudyPracticeInterviewsYouTubeCoursesAbout
Log inGet Started
Topics/Tree Algorithms
advanced level

Tree Algorithms

Quick Answer

What is Tree Algorithms?

Trees are connected acyclic graphs, and they appear everywhere in competitive programming: from basic DFS traversals to advanced techniques like binary lifting for LCA queries. RunTimeFix covers tree algorithms systematically: rooting a tree, computing subtree sizes, finding the diameter (longest path), calculating distances between vertices, binary lifting for O(log n) ancestor queries, Lowest Common Ancestor (LCA), and Euler tour for flattening tree queries into array range queries. Each technique builds on the previous, creating a complete toolkit for tree problems.

  • tree algorithms
  • rooted trees
  • DFS on trees
  • tree diameter
  • binary lifting
  • LCA
  • Euler tour
  • subtree queries

Study Material for Tree Algorithms

Ch 24: Rooted Trees — DFS, Subtree Size & Diameter

Tree Terminology · Rooting a Tree · Tree Diameter · Distance Between Two Vertices · Tree Algorithms: Summary of Techniques

Ch 25: Binary Lifting, LCA & Euler Tour

Binary Lifting · Lowest Common Ancestor (LCA) · Euler Tour

Related Topics

Graphs & Graph AlgorithmsData StructuresSegment Tree & Fenwick Tree
Was this helpful?

Published by RunTimeFix · Comprehensive guides for competitive programming

>RunTimeFix

Practical programming education. Books, videos, courses, and hands-on learning for competitive programming, DSA, and software engineering.

RunTimeFix

  • About
  • YouTube
  • Book
  • Study Library
  • Courses

Learn

  • Competitive Programming
  • DSA
  • Development
  • Databases

Legal

  • Privacy
  • Terms
  • Refund Policy

RunTimeFix — debug → solve → run

© 2026 RunTimeFix. All rights reserved.