I've seen code for a binary tree traversal function, and saw it was using double recursion:
public static void PrintTree(BinNode<int> t)
{
if (t != null)
{
Console.WriteLine(t.GetValue());
PrintTree(t.GetLeft());
PrintTree(t.GetRight());
}
}
What I don't understand is what C# does first - does it do both recursions at once, or does it do the first and then 'saves' the other, and if so when does it switch to other ?- there is only one exit statement and it also exits the second recursion(PrintTree(t.GetRight());) so how exactly does it get called?