# Is there a name for this tree traversal?

This came when I was looking at block scoping in compiler design.

{   A   { B }   { C {D} {E} }   }


For the above pseudo code, the order in which the scope varies as we scan left to right is A B A C D C E C A, where A to E represent scopes.

A parse tree can be constructed for the above pseudo code:

  A
/ \
B   C
/ \
D   E


Is their a term for such a traversal order, which for the above tree is A B A C D C E C A?

• DFS? – xskxzr Apr 8 '18 at 13:43
• – Luke Mathieson Apr 8 '18 at 13:50
• @LukeMathieson not pre-order. Main difference is, what we normally call traversal do not represent a tree vertex more than once within the output string. – Apiwat Chantawibul Apr 8 '18 at 14:05
• @billiska: but nothing stops you from doing more than one action during a DFS. In this case, there are pre-, in- and post-order actions. – rici Apr 8 '18 at 15:34