Binary Trees/Inorder: Difference between revisions
From charlesreid1
(→Flags) |
|||
| Line 18: | Line 18: | ||
</pre> | </pre> | ||
=Related Pages= | |||
Preorder, postorder, and in-order traversals on trees: | |||
* [[Binary Trees/Inorder]] | |||
* [[Trees/Postorder]] | |||
Breadth-first and depth-first traversals on trees: | |||
* [[DFS]] | |||
* [[BFS]] | |||
Graphs, generalization of tree structures: | |||
* [[Graphs#Graph Traversals]] | |||
=Flags= | =Flags= | ||
{{TreesFlag}} | {{TreesFlag}} | ||
[[Category:Trees]] | [[Category:Trees]] | ||
[[Category:Binary Trees]] | |||
[[Category:Traversal]] | [[Category:Traversal]] | ||
[[Category: | [[Category:Algorithms]] | ||
[[Category:Recursion]] | [[Category:Recursion]] | ||
Revision as of 12:23, 7 September 2017
Notes
The basis of in-order traversal is that the binary tree be sorted. This implements the convention of a sorted binary tree, a recursive definition:
The value of node k is greater than every node in the left subtree of node k. (Left goes first. Left to right precedence.)
The value of node k is less than every node in the right subtree of node k. (Right goes second. Left to right precedence.)
define inorder_traversal( tree ):
inorder_traversal( tree, root, 0 )
define inorder_traversal( tree, position, depth ):
inorder_traversal( tree, position.left(), depth+1 );
// perform visit action on position
inorder_traversal(tree, position.right(), depth+1 );
Related Pages
Preorder, postorder, and in-order traversals on trees:
Breadth-first and depth-first traversals on trees:
Graphs, generalization of tree structures:
Flags
| Trees Part of Computer Science Notes
Series on Data Structures Abstract data type: Trees/ADT Concrete implementations: Trees/LinkedTree · Trees/ArrayTree · SimpleTree
Tree Traversal Preorder traversal: Trees/Preorder Postorder traversal: Trees/Postorder In-Order traversal: Binary Trees/Inorder Breadth-First Search: BFS Breadth-First Traversal: BFT Depth-First Search: DFS Depth-First Traversal: DFT OOP Principles for Traversal: Tree Traversal/OOP · Tree Traversal/Traversal Method Template Tree operations: Trees/Operations Performance · Trees/Removal
Tree Applications Finding Minimum in Log N Time: Tree/LogN Min Search
Abstract data type: Binary Trees/ADT Concrete implementations: Binary Trees/LinkedBinTree · Binary Trees/ArrayBinTree Binary Trees/Cheat Sheet · Binary Trees/OOP · Binary Trees/Implementation Notes
|