Maximum independent set in a tree

ID: maximum-independent-set-in-a-tree

Root a finite tree. The two dynamic programming states are the optimal size in the descendant subtree when its root is included, , or excluded, . The sums run over its children. Inclusion forces every child to be excluded; exclusion permits each child's better state. Child subtrees have no edges between them, which proves independence of these choices. The leaf states are , and the root's better state gives the optimum.
A postorder traversal computes the states in time and storage. Reconstruct a set by following an attaining root choice and the same child constraints, breaking ties arbitrarily. The empty and singleton cases use the ordinary non-strict subset convention.

New to topics? Read the docs here!