While browsing the tree after a find operation move to the next child node, direction 0 is lesser direction !0 is greater.
Binary Trees have a 'current' cursor. These operations may be used to browse the tree.
// this assumes you have a tree, and it's fairly populated, then this demonstrates // all steps of browsing. POINTER my_data; // go to the 'leftmost' least node. (as determined by the compare callback) my_data = GetLeastNode( tree ); // go to the 'rightmost' greatest node. (as determined by the compare callback) my_data = GetGreatestNode( tree ); // move to the node that is less than the current node. (move to the 'left') my_data = GetLesserNode( tree ); // move to the node that is greater than the current node. (move to the 'right') my_data = GetGreaterNode( tree ); // follow the tree to the left down from here my_data = GetChildNode( tree, 0 ); // follow the tree to the right down from here my_data = GetChildNode( tree, 1 ); // follow the tree up to the node above the current one. // (the one who's lesser or greater points at this) my_data = GetParentNode( tree ); // this is probably the least useful, but someone clever might find a trick for it // Move back to the node we were just at. // (makes the current the prior, and moves to what the prior was, // but then it's just back and forth between the last two; it's not a stack ). my_data = GetPriorNode( tree );
A more practical example...