B
B
becks2017-03-17 14:51:09
Mathematics
becks, 2017-03-17 14:51:09

Is it possible to build a segment tree from multiple queries?

Good afternoon!
I deal with the Segment Tree and look at typical tasks that this structure allows you to effectively solve on the requested segment. A typical task is finding the sum on a segment or finding a minimum / maximum, everything seems to be logical and understandable. But I have a question, is it possible to use this data type if not only the boundaries of the segment change, but also the attribute of some operation? What is this about. Suppose you need to find on the segment the number of elements divisible without remainder by x from the set X. That is, we have built a segment tree, and then we receive several requests as input, each of which contains the boundaries of the segment and a divisor, and, accordingly, for each such request we must give an answer. Will the tree need to be rebuilt?
If you provide a link where you can read more about this kind of features, I will be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Olohtonov, 2017-03-17
@sgjurano

At each vertex you have information about applying a predefined operation to the corresponding segment, if you change the operation and did not precalculate in advance, then you will have to recalculate the values ​​at all vertices, which is equivalent to rebuilding the tree from scratch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question