In your diagrammed structure (which is a directed acyclic graph or “DAG”, not a tree), a traversal will visit two children for every node except the leaf nodes. Therefore it will visit a total of 2h-1 nodes (counting duplicates), where h is the height of the DAG. (The height is 5 in your diagram.)
Assuming the DAG is fully populated, then n (the number of nodes in the DAG) must be h(h+1)/2. (This is Gauss's formula for summing the integers from 1 through h.)
Solving n = h(h+1)/2 for h gives us h = (sqrt(8n + 1) - 1)/2, so the total number of nodes visited, in terms of n, is 2(sqrt(8n + 1) - 1)/2 - 1.
UPDATE
The traversal function would look like this:
def traverse(node):
if node.left is not None:
traverse(node.left)
print(node.data)
if node.right is not None:
traverse(node.right)
Notice that traverse
doesn't look at a node's parent, only its children. From traverse
's point of view, it is irrelevant that some nodes are shared (and therefore have two parents). It cannot tell the difference between your DAG and a normal binary tree.
Every one of your DAG's interior nodes has exactly two children. So, from traverse
's point of view, your DAG is identical to a fully-populated binary tree of height h. A fully-populated binary tree of height h has 2h-1 nodes.