Graph Theory37 sections · 1633 units
Open in Course

Base Case - First Column

(Direct parents)

The first column is easy: up[v][0] is the parent of vv. If vv is the root, there is no parent. Set up[root][0] = root (or 1-1, or null, depending on your implementation).

This way, jumping up from the root keeps you at the root. For all other nodes, up[v][0] = parent[v]. You already have this from the input or from running BFS/DFS. This column serves as the foundation. Every later column builds on it through the recurrence relation.