I am learning binary tree and I am trying to understand why is Node left
calling class Node
again.
Eg:
class Node
{
Node left, right;
int data;
}
Why is Node
calling Node
and why it isn't int Node.
A binary tree is simply a structure that contains 0 to 2 references to the same type of object linked together. For example, this poorly drawn diagram:
10
/ \
1 5
/ \
3 6
10 is a Node
with:
left
references a Node
with value
1.right
references to a Node
with value
5.The other nodes are similar.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments