I am trying to program in C++ a binary search tree, but I am having trouble understanding what a successor is. Can someone help me out?
I am trying to program in C++ a binary search tree, but I am having trouble understanding what a successor is. Can someone help me out?
That's not any sort of standard terminology. A successor is, by the English definition, the thing that comes next. For example, "the successor to the throne." You don't need to know what any terminology means, you just need to know what a binary search tree looks like in order to implement one.
>I am having trouble understanding what a successor is.
A successor is the node with the next highest value.
6
3 8
2 5 7 9
4
In this tree, the successor of each node is the next node that would be given in an inorder traversal. For example, the successor of 2 is 3, but the successor of 3 is 4. The successor of 5 is 6, but the successor of 6 is 7. In this way, the successor doesn't refer to the structure of the tree, but rather the contained values. The successor could be right next to the node in question or several branches away, up or down the tree.