Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling a branching factor of 2 #40

Open
sharwell opened this issue Oct 12, 2017 · 1 comment
Open

Handling a branching factor of 2 #40

sharwell opened this issue Oct 12, 2017 · 1 comment
Labels

Comments

@sharwell
Copy link
Member

When a branching factor of 2 is used in a B+-tree data structure, it is possible for pathological tree shapes to be created where entire unnecessary index levels exist. A tree falls into this category if the following are all true:

  • The tree contains N data elements
  • The tree contains N leaf nodes (where each leaf node holds one data element)
  • The index level above the leaf nodes contains N index nodes (where each index node references one leaf node)

This situation can occur multiple times, resulting in substantial indirection between the leaf nodes and the root.

The easiest way to address this is requiring the branching factor to be at least 3. Trees with a branching factor require each node (except the last at each level) to contain at least 2 elements, resulting in a worst-case structure with binary fan-out. Other ways to address this also exist.

@sharwell
Copy link
Member Author

sharwell commented Jan 1, 2018

Another option for addressing this is modifying the algorithm to ensure two adjacent nodes cannot be merged into a single node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant