Calculate the depth of the tree
(self)
| 120 | random.setstate(prepop_state) |
| 121 | |
| 122 | def _calculate_tree_depth(self) -> int: |
| 123 | """Calculate the depth of the tree""" |
| 124 | |
| 125 | def get_depth(node, current_depth=0): |
| 126 | if node.is_leaf(): |
| 127 | return current_depth |
| 128 | if not node.children: |
| 129 | return current_depth |
| 130 | return max(get_depth(child, current_depth + 1) for child in node.children) |
| 131 | |
| 132 | return get_depth(self.btree.root) |
| 133 | |
| 134 | def verify_consistency(self) -> bool: |
| 135 | """Verify that B+ tree matches reference implementation""" |