The efficiency of a tree array is mainly by dividing a line segment into small segments (where each small segment stores the interval of the 2^k size, which reduces the interval and the complexity of the problem to logn), rather than a single point
The Add () operation modifies the value of a single point and updates the subsequent parent node (the only time that the point is updated and the parent node of that point is not updated, because the parent node of the point is included directly in the summation, so the point is skipped and the point is not accepted, so it needs to update itself. Instead of the parent node, the point is added directly to the summation, so there is no need to update it.
It is because of the difference between the Father node and the non-Father node that the Add () operation makes each sum () operation the correct value after the update
It is also because the tree array's add () can modify the interval after the point by modifying the single point, so the tree array can not only solve the simple single point modification and interval and query, but also can make interval point modification and single point query.
Where the single point of modification when the Add () modify the single point, sum () query interval and, while the interval point modification, add () modify the interval point change number, sum () query the number of changes in a single point
Hangzhou Electric oj1556http://acm.hdu.edu.cn/showproblem.php?pid=1556
Getting started with a tree array 2