"Introduction to Algorithms" The 11th lesson expanded data structure, dynamic ordered statistics and interval tree

Source: Internet
Author: User

This lesson focuses on how to construct the data structure you want, or to extend the capabilities of existing structures to achieve the specific functionality you want.


For example, design a dynamic structure that satisfies the function of finding the number of K-Large

the practice is to maintain the number of sub-nodes of each node to derive its rank without maintaining its rank, because dynamic operations make it difficult to maintain
Red-Black Tree insert operation 1. Tree Insert 2.rebalance


Build the basic flow of data structures you need to expand

1. Select a basic data structure such as a red-black tree
2. Decide which basic information to add to the node, such as implementing the query K-large function, the basic information that should be added is the sum of all the subtree nodes, rather than the rank of the node key value directly saved
3 Maintain insert + rotate/delete + rotate

4 encapsulation is a function that implements its function


later introduced a kind of interval tree, in fact, there are many related data structure, including line tree and its various variants, ranking tree, Chairman tree, etc., the main idea is to maintain some additional information to achieve the desired function, then I will update some examples in real time

"Introduction to Algorithms" The 11th lesson expanded data structure, dynamic ordered statistics and interval tree

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.