Based on this paper, I found that it is quite brilliant to use two BITs to do RMQ in O(lg N)
, as it is easier to code than segment tree, and the paper claims it performs better than other data structures as well.
I understand how to build the tree and how to do query operation, yet I am confused about the update operation. Here's the quotes:
We make the following observation: when we generate the associated intervals of the nodes we pass by, we can cover the whole interval [ p + 1, y ] by starting from node p + 1 and climbing the first tree (Fig. 2.1). So instead of doing a query for every node we update, we compute the results of the queries on the fly by climbing the tree once.
Analogously, we can update all the intervals of the form [ x, p – 1] by starting from node p – 1 and climbing the second tree (Fig. 2.2). The same algorithm is applied for updating both trees.
I suspect it should be the other way round: for finding minimum of interval [p+1, y], we should use the second tree instead of the first one; for finding minimum of interval [x, p-1], we should use the first tree instead.
My question is: Am I correct? If no, can someone give a simple example to demonstrate how the update operation works?