Two K Minus One

A virtual tree built from kk key nodes of an nn-node tree. How big is it, and why?

A

At most 2k−12k - 1 nodes: sort the key nodes by DFS order and add the LCA of each adjacent pair. Every added node is a branching point of the key set, and a tree with kk leaves has fewer than kk internal branchings. Construction is Θ(n)\Theta(n) per query, rerunning the DFS.

B

At most 2k−12k - 1 nodes: sort the key nodes by DFS order and add the LCA of each adjacent pair. Every added node is a branching point of the key set, and a tree with kk leaves has fewer than kk internal branchings. Construction is O(klog⁡n)O(k \log n).

C

Θ(klog⁡n)\Theta(k \log n) nodes: sort the key nodes by DFS order and add the LCA of each adjacent pair. Every added node is an ancestor of some key node, and a tree of depth log⁡n\log n contributes one chain per key node. Construction is O(klog⁡n)O(k \log n).

D

At most 2k−12k - 1 nodes: sort the key nodes by DFS order and add the LCA of every pair. Every added node is a branching point of the key set, and a tree with kk leaves has fewer than kk internal branchings. Construction is O(k2log⁡n)O(k^2 \log n).