I want to implement a 2d binary tree which means that each node of the main tree contains an int value and a reference to another tree. How do i write this reference to another tree in java?
The whole concept of pointers in java is still really confusing to me so I'd appreciate any kind of help.
Here's my code so far:
{
//class Node fields:
public int key;
public Node leftChild;
public Node rightChild;
public Node root;
public Node(int key) //class Node constructor
{
this.key = key;
//root = null;
}
}
public class TwoDimTree
{
// class TwoDimTree fields:
private Node root;
private int key;
public TwoDimTree()
{
root = null;
}
public void insert(int x, int y)
{
Node node = new Node(x);
node = new Node(y); /// is that how you create the reference to the other tree???
}
}```