Defining the structure of a binary tree and its basic terminology (root, leaf, parent, child).
A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. A binary tree can be empty, or it can consist of a single special node called the root, which has zero, one, or two subtrees, each of which is also a binary tree. This recursive definition is key to understanding and writing algorithms for trees. The basic terminology is essential: The **Root** is the topmost node in the tree. A node with no children is called a **Leaf** node. A node that is not a root or a leaf is an internal node. For any node, the node above it in the hierarchy is its **Parent**, and the nodes directly below it are its **Children**. Nodes with the same parent are **Siblings**. The **Height** of a tree is the length of the longest path from the root to a leaf. A binary tree is considered **Full** if every node has either 0 or 2 children. A **Complete** binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. This structure is important for heap implementations. Understanding these definitions is the first step to working with trees.