A binary tree is a type of tree where each node can have at most 2 children. The children of a node in a binary tree are usually referred to as the left and right nodes of the parent.
A perfect binary tree is any binary tree in which every node but the leaf nodes are full (that is they all have 2 children nodes), and all the leaf nodes are on the same level.
Each level of a perfect binary tree has exactly
A complete binary tree is any binary tree in which the following conditions are met:
A full binary tree is any binary tree in which all nodes either have two children or are leaf nodes.
In-order traversal is a type of depth-first traversal for binary trees in which the left subtree is visited and then the current node is visited and finally the right subtree is visited.
class BinaryTreeNode:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def in_order_traverse(root, visit):
if root is None:
return
in_order_traverse(root.left, visit)
visit(root.value)
in_order_traverse(root.right, visit)