I need to construct a tree in Java. I am already done with tree as a data structure. But I am having some problem feeding data from an array to the tree. Here is what I need to do.
domain = {"b", "c"};
then, the tree should be like:
null -> b,c
b->c c->b
So basically I want a node’s child to have all children from the domain that are not already covered in the parent. The problem is that in spite of a lot of tries, I am not able to write code for doing it. I know it can be done with a reccursive function.
I do not want full code. Any hint towards the solution will be highly appreciated. Thank you.

P.S.
I’d clear the specification. “”Every node in the tree has all the values as children from the domain apart from the ones that are already covered in it or its parents””
as in the figure, a is the base (say null). It has all the values from the domain (b,c). b has c and c has b.
The specification says:
It is a little unclear, but I am assuming that covered in it or its parents means that a node with value
xis allowed if the valuexis not on the path from the node to the root. In that case the tree can be constructed like this (the language is Haskell):For example, given a root value
"a"and a list of domain values["b", "c", "d"], the program constructs a root node with value"a"and 3 children recursively constructed from:"b"and the domain["c", "d"],"c"and the domain["b", "d"],"d"and the domain["b", "c"].In pseudo-Python this is the algorithm of the Haskell program:
Here is a test of the
buildfunction that prints the tree of the example of the question and the example above:The test uses indentation to show the depth of each node in the tree: