So I am having trouble finding the correct ancestor in a 2-3 Tree. In a 2-3 Tree of arbitrary height, there are a couple of cases to look for.
My nodes are designed as follows:
template<typename DataType>
struct node{
Node<DataType> *child1; //left-child
Node<DataType> *child2; //middle-child (3-node only)
Node<DataType> *child3; //right-child
Node<DataType> *extraChild; //for splitting purposes
Node<DataType> *parent;
DataType key1; //key1 <= key2
DataType key2; //key2 <= extraKey (only when node needs to be split)
DataType extraKey; //for splitting purposes
};
Is there an algorithm or something similar to find the proper ancestor to a node?
For example, say we were looking for the ancestor of H (bottom of the provided tree), it is obvious from a visual perspective that ancestor of H is the H at the root of the tree. But that requires jumping up 4 parent links. The tree could be of arbitrary size which is the issue.
My goal in the end is to create an iterator that does an in order traversal of the 2-3 tree. The purpose of finding an ancestor node is that the ancestor node will be the in-order successor of the leaf node that is the right child of it's parent node. Again, as in the example provided above.