Binary Tree 31-3
Binary Tree 31-3
Algorithms
Day School 4
Shalini Rajasingham
Introduction to Binary Trees
• Definition of a Binary Tree: A binary tree is a tree data structure in
which each node has at most two children, referred to as the left
child and the right child.
• Basic Properties:
• Each node contains a key (value), a pointer to the left child, and a pointer to
the right child.
• The topmost node is called the root of the tree.
• A binary tree can be empty (null).
Terminology
• Node: The basic unit of a binary tree, containing data and pointers to child
nodes.
• Edge: The link between parent and child nodes.
• Root: The topmost node in a tree, with no parent.
• Leaf: A node with no children.
• Parent: A node that has one or more children.
• Child: A node that has a parent node.
• Sibling: Nodes that share the same parent.
• Depth: The number of edges from the root to a node.
• Height: The number of edges on the longest path from a node to a leaf.
• Level: The depth of a node + 1 (the root is at level 1).
Full and Complete Binary Tree