Check out a free preview of the full Tree and Graph Data Structures course

The "Tree Traversal Order" Lesson is part of the full, Tree and Graph Data Structures course featured in this preview video. Here's what you'd learn in this lesson:

Bianca describes preorder, inorder, and postorder tree traversal and explains what it means to use each one.


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.

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.

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.

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.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now