Tree and Graph Data Structures Tree Traversal Order
Transcript from the "Tree Traversal Order" Lesson
>> Bianca Gandolfo: Really quickly. There are different types of trees. Are there different types of orders that I kind of have been alluding to we haven't explicitly talked about yet. So we have pre order, in order in post order. And I don't think it really matters that you memorize which ones which and why.
[00:00:21] I don't think like the people are going to be like, traverse a tree post order. You just need to understand like how to switch between these depending on the problem that you're solving. So let's just look at it. So a lot of it has to do with where you traverse.
[00:00:39] If you traverse first, or do the work, right? Whether that's the console.log or whatever it is you may be doing. So for this one, it will go through all of the left, then the root, and then all of the right. This one is the one that we've been working with where we do work on the root first, and then we do left, and then we do right.
[00:01:06] And this one is the opposite of that where you go to the left. Then you go to the right, and then you do work on the root.