You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A fundamental feature of any tree structure is node insertion, in the case of the sumtree mechanism we must insert only leaf nodes.
Suggested Design
This insertion can be done using a recursive function on the Node struct. Using recursion to traverse the tree we can determine insertion logic based on priority when reaching a decision point. For any node there are four possibilities for either children:
Child does not exist
Child is internal
2a. Child is internal and new node is out of range
2b. Child is internal and new node is in range
Child is a leaf
Using this we can determine there are 12 possible outcomes, however some priorities may cover multiple conditions. The following priority should suffice for first iteration insertion:
New node fits in either left or right range, insert accordingly
Left is empty, insert left
Incompatible left, Right is empty, insert right
Left is leaf, split left
Left is incompatible, right is leaf, split right
Here "splitting" a node involves creating a new internal node and assigning the split node and the new node as ordered children. It's very likely we may be able to simplify these conditions in future, or alter them to aid with balancing the tree.
Acceptance Criteria
Sumtree insertion logic
Unit-testing
The text was updated successfully, but these errors were encountered:
Background
A fundamental feature of any tree structure is node insertion, in the case of the sumtree mechanism we must insert only leaf nodes.
Suggested Design
This insertion can be done using a recursive function on the
Node
struct. Using recursion to traverse the tree we can determine insertion logic based on priority when reaching a decision point. For any node there are four possibilities for either children:2a. Child is internal and new node is out of range
2b. Child is internal and new node is in range
Using this we can determine there are 12 possible outcomes, however some priorities may cover multiple conditions. The following priority should suffice for first iteration insertion:
Here "splitting" a node involves creating a new internal node and assigning the split node and the new node as ordered children. It's very likely we may be able to simplify these conditions in future, or alter them to aid with balancing the tree.
Acceptance Criteria
The text was updated successfully, but these errors were encountered: