Skip to main content

Tree Algorithms

  • Chapter
  • First Online:
Guide to Competitive Programming

Part of the book series: Undergraduate Topics in Computer Science ((UTICS))

  • 195k Accesses

Abstract

The special properties of trees allow us to create algorithms that are specialized for trees and work more efficiently than general graph algorithms. This chapter presents a selection of such algorithms. Section 10.1 introduces basic concepts and algorithms related to trees. A central problem is finding the diameter of a tree, i.e., the maximum distance between two nodes. We will learn two linear time algorithms for solving the problem. Section 10.2 focuses on processing queries on trees. We will learn to use a tree traversal array to process various queries related to subtrees and paths. After this, we will discuss methods for determining lowest common ancestors and an offline algorithm which is based on merging data structures. Section 10.3 presents two advanced tree processing techniques: centroid decomposition and heavy-light decomposition.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Sleator and Tarjan [29] introduced the idea in the context of their link/cut tree data structure.

  2. 2.

    The notation \(\log ^k n\) corresponds to \((\log n)^k\).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Antti Laaksonen .

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Laaksonen, A. (2017). Tree Algorithms. In: Guide to Competitive Programming. Undergraduate Topics in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-319-72547-5_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-72547-5_10

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-72546-8

  • Online ISBN: 978-3-319-72547-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics