Discussion Data Structure - block

Data Structure - block

Block is a very easy to understand, very well written data structure. Rather than block is a data structure, rather it is an "algorithm" or even a "thinking." Personally, I think, thought, and divide and conquer chunked like. Their basic implementation can be summarized as: a big problem split into a number of small problems, small problems to solve after the last complete summary of the answers will come to the big questions.

Basically block is such that: for a length \ (N \) sequences, we break it into \ (\ sqrt N \) blocks, (of course, the number of elements of each course is \ (\ sqrt N \) th), we maintain a violent interval for each block. Finally able to deal with the \ (\ sqrt N \) answer to sub-question, when we want to count a range of issues, we can block the statistical answer is completely covered in this section, for individual beyond the statistics to further violence .

As a data block structure, its maintenance Enumeration Based on violence. You may be thinking: this data structure and violent enumerate what is the difference? But the enumeration block and in fact very different. This is because the block just to run again will be able to handle the answers to all blocks, when the final tally is in blocks of statistics without the need to re-engage in violence. The time complexity of the block is \ (O (NlogN) \) , we count, you will find that it can not be much faster than the enumeration of violence. In fact, it is indeed all sections of statistical data structure of a minimum efficiency (such as other tree line, Fenwick tree, etc.), but it has its own advantages: easy to understand, easy to implement. This is also the reason for the existence of it as a practical data structure - in the examination room when we can not 100% guarantee that knock themselves out of advanced data structures (hand line and tree line, etc.) is correct, it might as well use a simple easy to write the block Although Debu full marks, but in the case of card data structure is not deliberately block the deal with a 60-80 points is not a problem, RP little better even AC. Therefore, the block is indeed an easy to learn and easy to useCheat distraction techniquesTips.

Guess you like

Origin www.cnblogs.com/fusiwei/p/11432436.html