Skip to content

My solution to all the CSES Tree Algorithms Problems.

Notifications You must be signed in to change notification settings

pro-30/Tree-Algorithms

Repository files navigation

Tree-Algorithms

My solution to all the CSES Tree Algorithms Problems.

Problems available at : https://cses.fi/problemset/list/

  1. Subordinates : Dynamic Programming to calculate subtree size rooted at each node.

  2. Tree Matching : Dynamic Programming on Trees.

  3. Tree Diameter : 1st solution based on Proof of Diameter. 2nd using Dynamic Programming on Trees where we try all possible paths.

  4. Tree Distances I : Dynamic Programming on Trees + Rerooting Technique.

  5. Tree Distances II : Dynamic Programming on Trees + Rerooting Technique.

  6. Company Queries I : Binary Lifting(which in itself is a Dynamic Programing Approach).

  7. Company Queries II : Answer LCA queries in O(logn) Time Using Binary Lifting . (Note: Binary Search + Binary Lifting Will give TLE because it will be O(log²n) per query ).

  8. Distance Queries : Binary Lifting.