1
$\begingroup$

We are given a vector $\mathbf{b}$ of size $h$. Initially we have $\mathbf{b}_i=1$ for all $i\in \{1, 2, \ldots, h\}$. In a sequential fashion, at each time step $t=1, \ldots, n$, an index $j(t)$ is (adversarially) selected from $\{1, 2, \ldots, h\}$, $\mathbf{b}_{j(t)}$ is incremented by $1$, and the only information we receive is index $j(t)$.

We are also given a vector of integers $\mathbf{a}$ of size $h$. Our goal is to maintain over time vector $\mathbf{a}$, such that, at each time step for all $i\in \{1, 2, \ldots, h\}$ we have that $\mathbf{a}_i$ is equal to $\sum_{k=1}^i \mathbf{b}_k$ up to a constant factor (even a logarithmic factor in $n$ or $h$ would be acceptable). Initially (at time step $0$) each integer $\mathbf{a}_i$ is set to be equal to $\sum_{k=1}^i \mathbf{b}_k$ which in turn is equal to $i$.


Question: How can we build an algorithmic (possibly randomized) strategy to maintain over time vector $\mathbf{a}$ with a total (expected if randomized) number of elementary operations (i.e., the algorithmic time complexity) equal to $\mathcal{O}(n\log n)$ (or, if possible, $\mathcal{O}(n)$)?

$\endgroup$
7
  • $\begingroup$ If I understood correctly, one structure that helps you to do so is a Persistent Segment Tree. $\endgroup$ Commented Apr 18, 2020 at 23:12
  • $\begingroup$ Thank you Luis. With Persistent Segment Trees one can answer queries related to the sum of intervals in an array, which in this case corresponds to the the array $B[i]$ for $i\in\{1,2,\ldots,h\}$ of bins. Here, instead, we want to maintain $A[\cdot]$ updated overtime (up to a constant factor as I wrote above the question). This seems much more difficult, because, for any given approximation threshold, adding just one ball can require to simultaneously update $\Theta(h)$-many records of $A[\cdot]$. If you have any idea, I would be very happy to know it! $\endgroup$ Commented Apr 18, 2020 at 23:33
  • $\begingroup$ I think there is a trick for range updates on Segment Trees called "lazy propagation" which is useful. $\endgroup$ Commented Apr 18, 2020 at 23:42
  • $\begingroup$ Thanks. I will take a look at that. $\endgroup$ Commented Apr 18, 2020 at 23:46
  • 1
    $\begingroup$ Do you want all of $\boldsymbol a$ to exist all the time, or do you just want to find $a_i$ when you need it? $\endgroup$ Commented Apr 19, 2020 at 12:31

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.