Data Structure Summary

Source: Internet
Author: User

since I have not written a tree-like array [cover face], new open a pit Qaqaq tree-like array

Tree-like array supports single-point modification + interval and query single-point modification + interval max-value query interval plus minus + single-point query

Query/modify interval max, query/modify interval and, single-point modification
Lowbit (a) =aand (−a) lowbit (a) =a and (a)
Definition c[i]=a[i−lowbit (i) +1]+...+a[i] C[i]=a[i-lowbit (i) +1]+...+a[i]
A picture of a tree-like array must be

We can find that for any one c[i] c[i], if modified, will affect the c[i+lowbit (i)] c[i+lowbit (i)], so each up and down, and then modify, (written in recursive form)
query [L,r] [l,r] sum sum, become sum[1,r]−sum[1,r] sum[1,r]-sum[1,r] One- dimensional single-point modification + interval maximum value query

For single point modification, modify C[i] to compare C[i−20],c[i−21]......c[i−lowbit (i) +1] C[i-2^0],c[i-2^1]......c[i-lowbit (i) +1]
Interval maximum value query, for an interval [l,r], if R-lowbit (r) +1 in [L,r] then take C[r-lowbit (R) +1,r] comparison, if not, then R to R-1
[Bzoj 1012] [JSOI2008] Maximum number of maxnumber one-dimensional interval plus and minus + single point query

We use the differential sequence to maintain the modified single-point modification of the interval interval, because the differential sequence sequence requires a prefix and a single point of query, the tree array of interval query is exactly the prefix and to achieve, so the tree number assembly is the value of the difference
Make d[i]=a[i]−a[i−1] d[i]=a[i]-a[i-1]
Single point query a[i]=∑ij=1d[j] a[i]=\sum_{j=1}^id[j]
Maintain d[i] with a tree-like array d[i] This sequence can be
[BZOJ1782] [Usaco2010 Feb]slowdown slowly swim one-dimensional interval plus minus + interval query

With the basis of a single point query, we'll look at the interval query
∑ni=1a[i]=∑ni=1∑

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.