Your program should accept an argument from commmand line which denotes
size of your tree.
With input 0, only a process is created. (no fork() is needed).
With input 1, 3 process is created. (two fork() are needed).
The tree should be like
proctree
/ \
1st 2nd
With input 2, 5 processes is created, and the tree is like
proctree
/ \
left right
/ \
left right
With input 3, the tree should be like
proctree
/ \
left right
/ \
left right
/ \
left right
Each process will print its pid and its ppid.
And the messages of processes are printed in POST-order.
Example:
$ echo $$
214
$ ./a.out 0
I'm 845, and my parent is 214
$ ./a.out 1
I'm 847, and my parent is 846
I'm 848, and my parent is 846
I'm 846, and my parent is 214
$ ./a.out 2
I'm 851, and my parent is 850
I'm 852, and my parent is 850
I'm 850, and my parent is 849
I'm 853, and my parent is 849
I'm 849, and my parent is 214
$ ./a.out 3
I'm 857, and my parent is 856
I'm 858, and my parent is 856
I'm 856, and my parent is 855
I'm 859, and my parent is 855
I'm 855, and my parent is 854
I'm 860, and my parent is 854
I'm 854, and my parent is 214
$