title: How many nodes have only one child in a binary tree?
body: <p>I want to calculate how many nodes from a binary tree have only one child. I don't know if this is ok. Also I don't know if I have to use a tree search like postorder. </p>
  
  <pre><code>size_t tree_one_child(const tree_t* t){
  if(!t || number_children(t)==0){
      return 0;
  }
  if(number_children(t)==1){
      return 1 + tree_one_child(t-&gt;left) + tree_one_child(t-&gt;right);
  }
  else{
      return tree_one_child(t-&gt;left) + tree_one_child(t-&gt;right);
  }
  
  
  
  size_t number_children(const tree_t* t){
  int count = 0;
  if(t-&gt;left != null ) count++;
  if(t-&gt;right != null) count++;       
  return count;
  }
  </code></pre>