Konjac tree-lined review - some of the solution on a restricted range of elements queries

As the title: This paper illustrates the interval for some solution to limit the query (in fact, two)

Question 1: Given a number of columns, the query requires all L-R interval is greater than or less equal to Va and Vb element

solution:

1. segment tree sets of weights segment tree

  1. The first elements of the maintenance section dimension, a second dimension as the weight segment tree, maintained range between A-B and
  2. Vila to each query from the first to the corresponding section, then the weights determined in line with Va and Vb query tree can range

2. Block

  1. Array referred to as a block, a block for each array are open b a, b array after ordering a copy block element, the new C, for each of a and b are seeking prefix
  2. For purposes of this block, the position Va and Vb in the array b Ia, Ib with diethyl points, then that is c [lb] -c [la-1] in the contribution of this array.
  3. Scattered portion violence, no more than 2 * sqrt (n)

Question 2: seeking the number of elements on the basis of a

solution:

1. segment tree sets of weights segment tree

  1. Almost as above, to maintain the number of elements in the second activist value segment tree (may be discrete)

2. Block

  1. Array block referred to as a, for each block is a one weight open array b, b a record number of each element appears
  2. b ranges MinV-MaxV (discrete), for each record b c b to open a prefix and an array
  3. Suppose the discrete Va, Vb to map [Va], map [Vb], the contribution to the block c [map [Vb]] - c [map [Va] -1]

 

Question 3: Adding modified on the basis of the conditions 1 and 2 are on: either to delete a certain element (normal topic and people should not be doing things like this), modify the value of a certain element of

solution:

1. segment tree sets of weights segment tree

  1. Probably as above, the inner layer while maintaining the number of occurrences and weights and can be
  2. However, in the case of deleting the element, we have omitted to record the position, if after an operation carried out after this position, L and R 1 should be increased (corresponding to a rearward movement of Interval integrally make deleted space to the elements)
  3. Displacements of the above may be an array of recording, deleting every time it takes time for the n location of the omitted elements ++, the actual operation of adding L and R are the corresponding elements in the array

2. segment tree cover Splay (supporting the tree-lined read konjac review --Splay)

  1. Outer segment tree maintenance intervals, while maintaining the inner Splay weight and the number of elements and their sub-trees, but still the node weights of the weight of the element (and not sub-tree)
  2. First find the query node Va, Vb on behalf of (if Va and Vb does not exist, to find precursors Va and Vb successor) will rotate to the root precursor Va, Vb of the rotation on the right successor to the son of precursor Va, this time we ask the interval Vb is the successor of the entire left subtree
  3. So you can find the answer to the above two, the section be merged
  4. For modifying element values, representative of Splay approach was to delete the original value of the point, and then point the new modified values ​​R and L represents added, omitted if the element is still maintained remove the outermost array, the inner puncturing corresponding element out to

3. Block segment tree sets of weights

  1. For the modification, and then use an array of ways it is a slow
  2. Maintenance block or the first array a, the inner segment tree using weights, as above
  3. Deleted records outermost array interval apart, modified L directly upon interrogation interval L to R, R to avoid the problems introduced into the segment tree

Question 4: perform common modifications on the basis of section 1 and 2 of the (deleted cancer too, the question people out of it waiting to be killed)

In this case the above three approaches to be deleted one by one, because the above approach is based on the weight of the operation, and such modifications are based on the ID

So, the conclusion is not maintained, because every time we have to redo or block the corresponding section of the inner tree.

Up file: in fact it is feasible

Weight balanced tree maintenance segment tree, each dot represents a point right inner peripheral balanced tree balanced trees exist at this point in the section of the L - R, there have been several

Then for the interval to modify, simply put in the corresponding inner section made into a balanced tree 0 (if the modified value is not the same weight and peripheral), or made into a section length (a peripheral and the modified weight value the same) can be a

Query asking if the weight on the segment tree which L-R for each point of the tree can be balanced

For each point right

Problem 5: 1 and 2 on the basis of the required modifications to the range of each element of Va-Vb between the L-R interval in

To keep it pits

 

Guess you like

Origin www.cnblogs.com/XLINYIN/p/12275407.html