I need to create a tree structure similar as the attached image in Java. I\'ve found some questions related to this one but I haven\'t found a convincing and well explained
In the accepted answer
public Node(T data, Node parent) { this.data = data; this.parent = parent; }
should be
public Node(T data, Node parent) { this.data = data; this.setParent(parent); }
otherwise the parent does not have the child in its children list