Getting started with a tree array 2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.