0% found this document useful (0 votes)
14 views2 pages

Rerooting DP Techniques in Trees

Uploaded by

Rajni Singla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Rerooting DP Techniques in Trees

Uploaded by

Rajni Singla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

‭ ‬‭Trees‬


‭Pattern 1: Distance Between Nodes‬
‭→ Binary Tree Distance Queries‬
‭→ Tree Diameter‬
‭→ Lowest Common Ancestor‬
‭→ Kth Ancestor of a Tree Node‬
‭→ Distance to Root‬

‭ attern 2: Sum of Distances‬


P
‭→ Sum of Distances in Tree‬
‭→ Tree Distances II‬
‭→ Sum of Root to Leaf Numbers‬
‭→ Tree Tilt‬
‭→ Diameter of Binary Tree‬

‭ attern 3: Subtree Queries‬


P
‭→ Subtree Sum Queries‬
‭→ Company Queries II‬
‭→ Subtree Size Queries‬
‭→ Path Sum III‬
‭→ Count Univalue Subtrees‬

‭ attern 4: Binary Lifting (LCA)‬


P
‭→ Lowest Common Ancestor‬
‭→ Binary Lifting Template‬
‭→ Jump Game in Tree‬
‭→ Tree Ancestry Queries‬
‭→ Tree Path Queries‬

‭ attern 5: Tree DP‬


P
‭→ House Robber III‬
‭→ Tree Matching‬
‭→ Tree DP Template‬
‭→ Largest Independent Set‬
‭→ Maximum Path Sum‬

‭ attern 6: Rerooting Technique‬


P
‭→ Tree Distances I‬
‭→ Tree Distances II‬
‭→ Sum of Distances in Tree‬
‭→ Rerooting DP Template‬
‭→ Tree Diameter‬
‭ attern 7: Path Queries‬
P
‭→ Path Sum‬
‭→ Path Sum II‬
‭→ Longest Path in Tree‬
‭→ Query on a Tree‬
‭→ Kth Smallest Path Sum‬

‭ attern 8: Tree Construction‬


P
‭→ Construct Binary Tree from Preorder/Inorder‬
‭→ Serialize and Deserialize Binary Tree‬
‭→ Reconstruct Itinerary‬
‭→ Build Tree from Leaf Sequence‬
‭→ Recover Binary Search Tree‬

You might also like