Binary tree traversal

So I'm reading up on binary trees (I wanted to challenge myself and learn a new topic in c++) and as a side exercise there's a question that's been stumping me.

Two algorithms for traversing a binary tree take the same form and use an extra ADT for bookkeeping:

[
1
2
3
4
5
6
7
8
9
10
i]Put the root of the tree on the list[/i]
while(the ADT is not empty)
{
Remove a node from the ADT and call it n
Visit n
if(n has a left child)
    Put the child in the ADT
if(n has a right child)
    Put the child in the ADT
}


So my book says that the difference between the two algorithms is the approach for choosing a node n to remove from the ADT.

Algorithm 1: Remove the newest (most recently added) node from the ADT.
Algorithm 2: Remove the oldest (earliest added) node from the ADT.

In what order would each algorithm visit the nodes of the tree in following image?
http://imgur.com/AsL0h

Topic archived. No new replies allowed.