public void Print(TreeDSNode root, List <int> path) { if (root == null) { return; } path.Add(root.Value); if (root.isLeftNodeNull() && root.isRightNodeNull()) { String pathStr = string.Join(",", path); console.WriteLine("Tree path: " + pathStr); } else { if (root.isLeftNodeAvailable()) { Print(root.Left, new List <int>(path)); } if (root.isRightNodeAvailable()) { Print(root.Right, new List <int>(path)); } } }
private bool isHalfNode(TreeDSNode currentNode) { return((currentNode.isLeftNodeAvailable() && currentNode.isRightNodeNull()) || (currentNode.isRightNodeAvailable() && currentNode.isLeftNodeNull())); }
private bool isLeafNode(TreeDSNode currentNode) { return(currentNode.isLeftNodeNull() && currentNode.isRightNodeNull()); }