quartz/content/notes/tree-traversal.md
Jet Hughes eec8badee0 update
2022-04-28 11:51:17 +12:00

31 lines
565 B
Markdown

---
title: "tree-traversal"
aliases: traversal
tags:
- cosc201
---
Visit each node in the tree once. So we need to visit n, all the nodes in L, and all the nodes in R. We can do this in four different ways
preorder
- visit n
- traverse L
- traverse R
Inorder.
- traverse L
- visit n
- traverse R
Creating an BST from an array using the add operation then doing an inorder traversal is effectively a [quicksort](notes/quicksort)
postorder
- traverse L
- traverse R
- visit n
level order
- vist the root
- visit the roots children
- visit their children
- etc