YUNOVA · Data Structures & Algorithms · Module 11: Advanced dynamic programming

DP on trees

Notes for offline study · 30 November 2026

DP on trees

Key points

  • Tree DP computes each node's answer from its children's answers using DFS.
  • Many problems keep two states per node, such as taken and not taken.
  • Rerooting finds the answer for every node as the root in O(n).

Free on YUNOVA · yunova.in · Sign in to add your own lesson notes to this sheet.