If I have a tree as below:
A Root Level
/ \
/ \
G Z Level 1
/ \ / \
/ \ / \
C D T J Level 2
I have three questions:
How can I traverse this tree such that Level 1 nodes are printed first, then root level, and then level 2
G, Z, A, C, D, T, J
How can I traverse this tree such that Level 1 nodes are printed first, then level 2, and then root level
G, Z, C, D, T, J, A
How can I traverse this tree such that Level 2 nodes are printed first, then level 1, and then root level
C, D, T, J, G, Z, A
I'm going through tree traverals on wikipedia and remembered an old question I was once asked in an interview. I believe the question was either of the above three (most likely first or second).