For each $fork()$ function call, the parent creates one child. So, there are $2$ child nodes for each fork call (i.e. one parent + one child). The above example creates a complete binary tree, where each level from $1$ to $n$ describes a total number of children after a $fork()$ system call. After, $n$ level, the tree is left with one parent + $(n-1)$ child, each of which executes the printf(“*”). For each iteration of the for loop, the print(“*”) will be executed.

$\therefore$ total number of $* =$ (total number of nodes possible for tree with n+1 height) – 1
$=(2^{n+1}-1) – 1$
$=2^{n+1}-2$
ex- for n=2, total number of * will be $2^3-2=6$
