Examples :
$ echo $$
2419 <------- pid of the shell
$
For the tree, shell
|
a
the preorder traversing direction is "du".
That is: shell "d"own to a, a "u"p to shell.
$ ./a.out du a
I'm a, my pid=2757, and my ppid=2419
$
for the tree, shell
|
a
|
b
the preorder traversing direction is "dduu".
That is: shell "d" to a, a "d" to b, b "u" to a, a "u" to shell
$ ./a.out dduu ab
I'm b, my pid=2759, and my ppid=2758
I'm a, my pid=2758, and my ppid=2419
$
shell
|
a
/ \
b c
$ ./a.out dduduu abc
I'm b, my pid=2761, and my ppid=2760
I'm c, my pid=2762, and my ppid=2760
I'm a, my pid=2760, and my ppid=2419
$
shell
|
a
/ \
b d
|
c
$ ./a.out ddduuduu abcd
I'm c, my pid=2765, and my ppid=2764
I'm b, my pid=2764, and my ppid=2763
I'm d, my pid=2766, and my ppid=2763
I'm a, my pid=2763, and my ppid=2419
shell
|
a
/ | \
b d e
/
c
$ ./a.out ddduududuu abcde
I'm c, my pid=2770, and my ppid=2769
I'm b, my pid=2769, and my ppid=2768
I'm d, my pid=2771, and my ppid=2768
I'm e, my pid=2772, and my ppid=2768
I'm a, my pid=2768, and my ppid=2419
$