Segment-Based Dynamic Programming for Optimal Binary Search Trees: A Sub-Cubic Algorithm with Hierarchical Weight Partitioning
TAPON KUMER RAY, Rajkumar Yesuraj
ICLR 2026 submission
Abstract. Constructing optimal binary search trees under two-way comparisons is significantly more challenging than in the classical three-way model: two-way comparisons induce complex “punctured intervals” in the Dynamic Programming (DP) state space, potentially resulting in exponential sub-problem growth. In particular, the state-of-the-art algorithm for two-way comparisons runs in O\left(n^4\right) time, which becomes infeasible for large datasets with millions of keys. The proposed work presents a novel O\left(n^2\log{n^2}\right) time algorithm for constructing optimal search trees with two-way comparisons, improving on the current best O\left(n^4\right) complexity. The approach introduces Hierarchical Weight Partitioning (HWP), a segment-based dynamic programming framework that partitions the weight space into hierarchical segments, enabling efficient pruning of equivalent sub-problems while preserving optimality. The algorithm leverages a multi-level segment tree data structure with adaptive threshold selection to achieve logarithmic improvements in both time and space complexity for practical instances. Experimental evaluation on synthetic and real-world datasets demonstrates 3 to 8 times speedups with up to 60% memory reduction compared to existing methods. Our work provides the first sub-cubic solution for this fundamental problem. These results impact new possibilities for efficient inference in AI systems that rely on search structures (e.g., decision-tree models or data indexes).
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…