Given a linked list tree, where A is the root, with 2 children B and C. And B has two children D and E, such that A->[B->C] C->[D->E] . In this case, there are 14 stable sets. A stable set is a possibly empty subset, S, of the vertices such that no two nodes in S are adjacent to each other in the tree.

How would I use recursion to count the stable sets of the tree?


public int StableSets()
{

ListNode child = children;
TreeNode tree = null;


while(child != null)
{
count++;
tree = (TreeNode) child.getData();
if (t!=null){
c += tree.StableSets();
if (child.getNext() != null){

}
}

child = child.getNext();
}

return c;

}