12/38
Part 3 of 7 · Your own stackLearn and do
Your stack takes the children right to left, and recursion left to right
Both walks go as deep as they can, in a different order.
Portugal
1, 1Lisbon District
2, 4Lisbon
3, 7Sintra
4, 6Cascais
5, 5Porto District
6, 2Porto
7, 3Both go as deep as they can before they back up. They differ in which child goes first. The last child pushed is the first popped, so your stack takes the children right to left.
Which one change makes your stack visit a tree in recursion's order?
Pick an answer above to see the rest