Questions tagged [segment-trees]
7 questions
4
votes
1 answer
Segment trees with insertion/deletion
I have a range-query problem to solve. This problem requires not only range queries and update, but also insert or delete an element of the array. There is a series of operations that must be done in the order that they appear in the input. The…
matheuscscp
- 345
- 1
- 4
- 12
3
votes
3 answers
Detect if an interval is fully covered by union of previous intervals in sequence
Given a sequence of intervals $I_1, I_2, \ldots$, is there an efficient way to detect whether some interval $I_i$ is completely contained in the union of the preceding intervals $I_1, \ldots, I_{i-1}$?
For example, in the sequence $(0, 5), (5, 10),…
MattDs17
- 163
- 5
1
vote
1 answer
A data structure for range minimum queries
Here is a data structure question in the comparison model that I can't answer.
I have an array $A$ of $n$ elements. I work in the comparison model, meaning that the elements can only be compared with each other. I would like to create a data…
Vasek
- 11
- 1
1
vote
1 answer
Find the largest segment within a queried range?
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term largest we mean among all the…
ishandutta2007
- 111
- 5
0
votes
0 answers
Zero sequence query in boolean array
I have a large array of bits of length $N$.
The query $f(k, m)$ means "find $kth$ zero in the array and the next $m-1$ zeros after it", $k \in [0, N-1], m \ll N$
Currently I use a segment tree over the bit array and my approaches were:
use kth zero…
Andrey Godyaev
- 297
- 1
- 9
-2
votes
2 answers
Given m intervals and an array of integers, your task is to minimize the number of operations in which you can make the elements of the array nonposit
You are given the number $m$ and $m$ intervals of the form $a_i, b_i, v_i$, where $a_i<=b_i$ and $v_i>0$ and also a number $n$ and an array $s$ of length $n$, where $s_i>0$. In one operation you can choose an interval say $j$ and decrease the values…
John
- 1
- 1
-3
votes
1 answer
Can you simulate the following process in $O(N.log N)$
Given an array $A[]$ of N integers.
pseudocode:
Traverse from left to right of this array.
Let's say you are standing at index $j$.
For each index i=1 to i=j-1, increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$.
Once done for all $i
sibillalazzerini
- 113
- 3