def count_nodes(root): # Base Case if root is None: return 0 # Create an empty queue for level order traversal queue = [] # Enqueue Root and initialize count queue.append(root) count = 0 # initialize count for full nodes while(len(queue) > 0): node = queue.pop(0) # if it is full node then increment count if node.left is not None and node.right is not None: count = count+1 # Enqueue left child if node.left is not None: queue.append(node.left) # Enqueue right child if node.right is not None: queue.append.node.right)
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence