🌳 Tree DP
USACO C++ Book · Interactive Visualizer
🌳 Tree DP — Maximum Independent Set Full Demo
Tree DP
O(N)
Step 0/11
📊 Tree Structure (node=id(val), blue brackets=[dp0,dp1])
🗂 DP State
dp[u][0]=skip u, dp[u][1]=select u
DFS Call Stack
Time:
O(N)
Space:
O(N)
💻 Code
Hint
Click
Next Step ▶
to start and observe how post-order DFS computes dp values from leaves to root.
◀ Prev
Next Step ▶
↺ Reset
0/11
Keyboard:
→
Next
←
Prev
R
Reset