0

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?

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Narue
0

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.

0

>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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.