Hey
i want to create a method which counts the nodes from a binary tree that have exactly one child
i did that but it returns error :S
Can anyone tell me what's going wrong ??

Thanks in advance

//Count nodes from BinaryTree1 that have exactly one child
      public static int countNodesOne(BinaryTree2 node)
      {
          if (node == null)
          {
              return 0;
            }
            else
            {
                if (int leftCount = countNodesOne(node.left = 1))
                {
                    else if (int rightCount = countNodesOne(node.right = 1)
                    {
                    return leftCount + rightCount;
                }
            }
        }
    }

if (int leftCount = countNodesOne(node.left = 1))

whats this? = is assignment operator not check for equality

should'nt this statement say:
node.left ==1

oh i haven't noticed that
thanks!

but the problem is that it returns an error saying '.class expected' :S
???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.