arXiv:2611.00388cs.DSOct 2026

Manuscript Offprint

arXiv:2611.00388

Online carpooling against an oblivious adversary

Yuhao Lei

YUHAO LEI

ABSTRACT. In the online carpooling problem, edges on nn vertices arrive one at a time and must be oriented immediately, so as to keep the difference between the indegree and the outdegree of every vertex small. We give a randomized online algorithm which bounds the largest absolute difference over the first TT edges by O((log⁡T)1/3)O((\log T)^{1/3}) with high probability on every input sequence fixed in advance. This proves a conjecture of Kulkarni, Reis and Rothvoss and matches the known worst case lower bound. The algorithm keeps the law of the discrepancy vector dominated in the convex order by a Gaussian measure, and forces the endpoint with the smaller discrepancy to receive the edge whenever the two discrepancies are far apart. In the analysis we show that a vertex of discrepancy DD is preceded by a set of O(D)O(D) vertices with total discrepancy Ω(D2)\Omega(D^2).

1. INTRODUCTION

1.1. Online carpooling and edge orientation. Let n≥2n \geq 2 and [n]={1,…,n}[n] = \{1, \ldots, n\}. In the online carpooling problem, edges arrive one at a time, and the tt-th edge joins two distinct vertices utu_t and vtv_t of [n][n]. When an edge arrives, an online algorithm must orient it, either from utu_t to vtv_t or from vtv_t to utu_t, without seeing the later edges and without revising earlier decisions. We call the endpoint whose discrepancy increases the receiver and the other endpoint the sender. The aim is to keep, at all times, the difference between the indegree and the outdegree of every vertex small. In the pairwise carpooling model inspired by Fagin and Williams [FW83], vertices represent people, each edge represents a shared ride, and its orientation determines the driver. The discrepancy of each vertex measures the deviation of that person's driving count from its fair share.

It is convenient to state the problem as an online vector balancing problem. For x∈Rnx \in \mathbb{R}^n we write x(i)x(i) for its ii-th coordinate, ∥x∥\|x\| for its Euclidean norm and ∥x∥∞=max⁡i∣x(i)∣\|x\|_\infty = \max_i |x(i)|, and ⟨⋅,⋅⟩\langle \cdot, \cdot \rangle denotes the standard inner product on Rn\mathbb{R}^n. Let 1i\mathbf{1}_i be the ii-th standard basis vector of Rn\mathbb{R}^n. We represent the tt-th edge by et=1ut−1vte_t = \mathbf{1}_{u_t} - \mathbf{1}_{v_t} and also call this vector an edge. The algorithm chooses a sign εt∈{−1,+1}\varepsilon_t \in \{-1, +1\}; the sign +1 means that the edge is oriented from vtv_t to utu_t. The discrepancy vector evolves by

(1.1)

d0=0,dt=dt−1+εtet(t≥1).d_0 = 0, \qquad d_t = d_{t-1} + \varepsilon_t e_t \quad (t \geq 1).

Thus dt(i)d_t(i) is the indegree minus the outdegree of the vertex ii in the graph formed by the first tt oriented edges. The quantity of interest is

(1.2)

MT=max⁡0≤t≤T∥dt∥∞.M_T = \max_{0 \leq t \leq T} \|d_t\|_\infty.

An adaptive adversary chooses ete_t after seeing ε1,…,εt−1\varepsilon_1, \ldots, \varepsilon_{t-1}. An oblivious adversary fixes the whole sequence before the algorithm starts, so that the edges do not depend on the random choices of the algorithm.

This paper is about the oblivious setting. All probabilities and expectations are over the internal randomness of the algorithm. A run is a realization of this randomness, and its trajectory is the resulting discrepancy sequence (dt)0≤t≤T(d_t)_{0 \leq t \leq T}.

YUHAO LEI

1.2. Background and main result. Online vector balancing goes back to the balancing games of Spencer [Spe77]. The subject has developed along several directions: stochastic arrivals where the input vectors are sampled from a distribution, adaptive adversary, and worst case arrivals fixed by an oblivious adversary. For independent arrivals from an arbitrary distribution on [−1,1]n[-1,1]^n, Bansal, Jiang, Singla and Sinha [BJSS20] obtained prefix discrepancy bounds polynomial in nn and log⁡T\log T. Their framework handles dependence among the coordinates of an arriving vector and also yields bounds for geometric discrepancy problems. For independent uniformly random vectors in {−1,+1}n\{-1,+1\}^n, Bansal and Spencer [BS20] achieved the optimal O(n)O(\sqrt{n}) terminal discrepancy with high probability. The subsequent development for stochastic arrivals by Bansal, Jiang, Meka, Singla and Sinha [BJM+21^{21}] developed a potential based approach that improved these bounds and extended the results to more general discrepancy settings.

Alweiss, Liu and Sawhney [ALS21] constructed a randomized online algorithm that, against an oblivious adversary, gave discrepancy bounds optimal up to polylog. Their self-balancing walk chooses each sign at random, biased bias toward the update that decreases the Euclidean norm of the discrepancy vector. Liu, Sah and Sawhney [LSS22] developed a closely related approach through random walks with a Gaussian stationary distribution. A significant advance of Kulkarni, Reis and Rothvoss [KRR24] established the optimal general bound O(log⁡T)O(\sqrt{\log T}) for vectors of Euclidean norm at most one, the online Komlós setting. They constructed an online algorithm for which every fixed prefix sum is subgaussian with an absolute parameter, and proved a matching lower bound against an oblivious adversary. Aden-Ali [AA26] subsequently provided an efficient algorithm with the same discrepancy order in O(nT)O(nT) time by coupling three Gaussian fixed point walks so that every update uses a sign in {−1,+1}\{-1,+1\}. Recent work also identifies how sparsity changes the problem. For vectors in [−1,1]n[-1,1]^n with at most dd nonzero coordinates, Altschuler and Tikhomirov [AT26a] obtained an efficient online algorithm with O(d)O(\sqrt{d}) prefix discrepancy down to nearly logarithmic sparsity: for any fixed η>0\eta>0, their bound applies when d≥Cη(log⁡T)(log⁡log⁡T)2+ηd\geq C_\eta(\log T)(\log \log T)^{2+\eta}. For T=Θ(n)T=\Theta(n) independent uniformly random binary vectors with exactly dd nonzero coordinates, they determined the optimal prefix discrepancy order Θ(max⁡{d,log⁡log⁡n})\Theta(\max\{\sqrt{d},\log \log n\}) when 2≤d≤n/22\leq d\leq n/2 in [AT26b]. Carpooling has fixed sparsity two and the additional structure that its two nonzero coordinates have opposite signs. For broader background on the algorithmic and geometric aspects of discrepancy, we refer to the survey of Bansal [Ban23] and the monograph of Bansal and Nikolov [BN26].

For carpooling, against adaptive adversaries the optimal order is known. Ajtai, Aspnes, Naor, Rabani, Schulman and Waarts [AAN+98^{98}] showed that an adaptive adversary can force discrepancy Ω(min⁡{T1/3,n})\Omega(\min\{T^{1/3},n\}), and Bansal, Prabhu, Singla and Sundaram [BPSS26, Theorem 1.1] proved the matching upper bound for the greedy algorithm, which orients each edge towards the endpoint of smaller discrepancy. They proved that for T=O(n)T=O(n) edges sampled independently and uniformly from a Δ\Delta-regular graph, discrepancy O((log⁡n)1/3)O((\log n)^{1/3}) is achievable with high probability, and asked whether O((log⁡T)1/3)O((\log T)^{1/3}) holds for edges sampled from an arbitrary graph [BPSS26, Section 1.1]. For related work on Greedy and on random inputs see [CNP+11^{11}, FKK+16^{16}, GKKS20].

Randomization helps against oblivious adversaries. A randomized algorithm of Kalai, reported by Naor [Nao05] gives MT=O(log⁡T)M_T = O(\log T) with high probability. Applying the general algorithms of [KRR24, AA26] to the normalized edge vectors et/2e_t/\sqrt{2} improves this to O(log⁡T)O(\sqrt{\log T}): each fixed time coordinate is subgaussian. A lower bound of order (log⁡T)1/3(\log T)^{1/3} is implicit in [AAN+98^{98}, Section 3.2]; see also [BPSS26, Section 1] and [FKK+16^{16}]. This is a worst case lower bound in which the number of vertices may grow with steps. Kulkarni, Reis and Rothvoss [KRR24, Conjecture 2] conjectured that a randomized online algorithm achieves the matching upper bound on every fixed edge sequence.

Conjecture 1.1 ([KRR24, Conjecture 2]). There is a randomized online algorithm for carpooling which, for every T≥1T \geq 1 and every sequence of TT edges fixed in advance, satisfies MT=O((log⁡T)1/3)M_T = O((\log T)^{1/3}) with high probability.

The goal of this paper is to prove this conjecture.

Theorem 1.2. For every n≥2n \geq 2 there is a randomized online algorithm, independent of TT, such that for every sequence of T≥1T \geq 1 edges on [n][n] fixed in advance and every integer D≥300D \geq 300, the maximum MTM_T defined in (1.2) satisfies

(1.3)

P(MT≥D)≤12Texp⁡[−(D40)3].\mathbb{P}(M_T \geq D) \leq 12T \exp\left[-\left(\frac{D}{40}\right)^3\right].

Consequently, for every c≥0c \geq 0, with probability at least 1−e−c1 - e^{-c},

(1.4)

MT<max⁡{300, 40(c+log⁡(12T))1/3}.M_T < \max\left\{300,\ 40\big(c+\log(12T)\big)^{1/3}\right\}.

In particular, this answers the question in [BPSS26, Section 1.1] for arbitrary graphs, with no regularity assumption or restriction on the time horizon.

1.3. Ideas of the proof. The geometric starting point is Banaszczyk's vector balancing theorem [Ban98] and the convex set transform in its proof. For a sufficiently short balancing vector, this transform does not decrease the Gaussian measure of a convex set whose measure is at least one half. This (sub)gaussian point of view also underlies the advances in [KRR24, LSS22, AA26] where the algorithms of [KRR24, AA26] provide the O(log⁡T)O(\sqrt{\log T}) discrepancy bound. To improve on O(log⁡T)O(\sqrt{\log T}) we consider backward witness, a variant of the spreadness argument of the recent advance [BPSS26, Lemma 3.3] whose witnesses are determined by the input and O(D2)O(D^2) ternary choices. A vertex of discrepancy DD leads backwards to a set SS of O(D)O(D) vertices carrying total discrepancy Ω(D2)\Omega(D^2). Subgaussianity bounds the probability of this by exp⁡(−Ω(D3))\exp(-\Omega(D^3)) so that a union bound over them gives the order (log⁡T)1/3(\log T)^{1/3} against an oblivious adversary.

We construct an algorithm in Section 3 with the following two properties:

(P1) after each edge is oriented, the receiver is ahead of the sender by at most a constant;

(P2) at every fixed time, dtd_t is subgaussian with a constant parameter.

Greedy has (P1), with the constant 2, but not (P2); the algorithms of [KRR24, AA26] have (P2) but are not known to have (P1). Without (P1), a single vertex can grow by receiving from vertices far below it: if n≥T+1n \geq T+1, the edges 11−1t+1\mathbf{1}_1 - \mathbf{1}_{t+1}, 1≤t≤T1 \leq t \leq T, arrive and the vertex 1 always receives, then its discrepancy reaches TT, while no other vertex is ever above 0.

Section 4 derives P(MT≥D)≤O(T)exp⁡(−Ω(D3))\mathbb{P}(M_T \geq D) \leq O(T) \exp(-\Omega(D^3)) from (P1) and (P2). Starting from a vertex i∗i^* that reaches discrepancy DD at the first such time t∗t^*, we walk backwards with a set SS, initially {i∗}\{i^*\}, and compare dt(S)=∑i∈Sdt(i)d_t(S) = \sum_{i \in S} d_t(i) with a threshold A(∣S∣)A(|S|). At an edge with exactly one endpoint in SS, we keep SS, add the outside endpoint or remove the inside one. These choices form a ternary tree determined by the input and the root (t∗,i∗)(t^*, i^*). Property (P1) ensures that one of the choices raises dt(S)−A(∣S∣)d_t(S) - A(|S|) by at least one. Following such choices leads to a set with total discrepancy Ω(D2)\Omega(D^2) once ∣S∣|S| is a fixed fraction of DD or after O(D2)O(D^2) crossings. We stop every path after at most O(D2)O(D^2) branching steps, giving exp⁡(O(D2))\exp(O(D^2)) leaves per root. Since i∗i^* is an endpoint of et∗e_{t^*}, there are at most 2T2T roots. The resulting family of leaves depends only on the input, and the union bound gives

P(MT≥D)≤Texp⁡(O(D2))⏟number of candidates⋅exp⁡(−Ω(D3))⏟bound from (P2).\mathbb{P}(M_T \geq D) \leq \underbrace{T \exp(O(D^2))}_{\text{number of candidates}} \cdot \underbrace{\exp(-\Omega(D^3))}_{\text{bound from (P2)}}.

YUHAO LEI

The algorithm in Section 3 keeps the law μt\mu_t of dtd_t dominated in convex order by the centered Gaussian measure γ\gamma on Rn\mathbb{R}^n with covariance 50 times the identity; exponential test functions then give (P2). The measure μt−1\mu_{t-1} is determined recursively by e1,…,et−1e_1, \ldots, e_{t-1}, and it is the law of dt−1d_{t-1}. When ete_t arrives, the algorithm chooses the probability of moving from xx to x+etx + e_t rather than to x−etx - e_t for each point xx of the support of μt−1\mu_{t-1} such that the new law is again dominated by γ\gamma and the endpoint that is behind receives whenever ∣x(ut)−x(vt)∣>27|x(u_t) - x(v_t)| > 27; this gives (P1) with the constant 29. Such a choice exists by Theorem 3.3 which is proved in two steps in Sections 5 and 6.

References (1)