data_structures.binary_tree.inorder_tree_traversal_2022

Illustrate how to implement inorder traversal in binary search tree. Author: Gurneet Singh https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/

Classes

BinaryTreeNode

Defining the structure of BinaryTreeNode

Functions

inorder(→ list[int])

insert(→ BinaryTreeNode | None)

If the binary search tree is empty, make a new node and declare it as root.

main(→ None)

make_tree(→ BinaryTreeNode | None)

Module Contents

class data_structures.binary_tree.inorder_tree_traversal_2022.BinaryTreeNode(data: int)

Defining the structure of BinaryTreeNode

data
left_child: BinaryTreeNode | None = None
right_child: BinaryTreeNode | None = None
data_structures.binary_tree.inorder_tree_traversal_2022.inorder(node: None | BinaryTreeNode) list[int]
>>> inorder(make_tree())
[6, 10, 14, 15, 20, 25, 60]
data_structures.binary_tree.inorder_tree_traversal_2022.insert(node: BinaryTreeNode | None, new_value: int) BinaryTreeNode | None

If the binary search tree is empty, make a new node and declare it as root. >>> node_a = BinaryTreeNode(12345) >>> node_b = insert(node_a, 67890) >>> node_a.left_child == node_b.left_child True >>> node_a.right_child == node_b.right_child True >>> node_a.data == node_b.data True

data_structures.binary_tree.inorder_tree_traversal_2022.main() None
data_structures.binary_tree.inorder_tree_traversal_2022.make_tree() BinaryTreeNode | None