Skip to content

ivanbgd/Binary-Tree-Traversals

Repository files navigation

Binary-Tree-Traversals

Contains both recursive and iterative implementations of in-order, pre-order, and post-order binary tree traversals.

The traversal algorithms are the same between the different files. The differences are in passing into and returning from functions.

Trees don't have to be binary search trees to use these traversal algorithms, meaning, they don't have to be in sorted order. These functions will traverse any binary tree. These functions don't do anything with nodes that they visit, but a user can call their function visit() which will do a desired thing with a node. It is noted in the code where it's appropriate to call the function.