Global Predecessor Indexing: Avoiding Binary Search in Weighted Job Scheduling
Amit Joshi
TL;DR
This work tackles Weighted Job Scheduling by eliminating the per-job binary search bottleneck in the classical DP solution. The authors introduce Global Predecessor Indexing (GPI), a two-phase preprocessing that sorts jobs twice and computes all predecessor indices via a linear-time two-pointer pass, yielding $O(S(n) + n)$ time and $O(n)$ when sorting is linear-time. The final DP then runs in $O(n)$ using precomputed predecessor indices, with parallelizability highlighted. Empirical results show substantial practical speedups over the traditional $O(n \log n)$ approach, including 2–3× improvements at $n=10^5$, due to better cache locality and elimination of repeated binary searches. Overall, GPI provides a simple, cache-friendly, and scalable solution for WJS and may extend to other problems that can leverage dual-sorting and linear predecessor computation.
Abstract
We present an improved solution to the Weighted Job Scheduling (WJS) problem. While the classical dynamic programming (DP) solution for $n$ jobs runs in $O(n \log(n))$ time due to comparison-based sorting and per-job binary search, we eliminate the binary search bottleneck. In its place, we introduce a novel multi-phase preprocessing technique called \emph{Global Predecessor Indexing (GPI)}, which computes the latest non-overlapping job (i.e., the predecessor) for all jobs via a two-pointer linear-time pass after sorting. This yields a time complexity of $O(S(n) + n)$ where $S(n)$ is the time to sort all jobs. GPI enables direct use in the classical DP recurrence. When combined with linear-time sorting, GPI yields a complete $O(n)$ solution. Even with comparison-based sorting, GPI significantly outperforms the classical solution in practice by avoiding repeated binary searches in favor of the more cache-efficient extra sort and two-pointer pass.
