# Formal definition of binary search tree

This is appropriate since recursion is an innate characteristic of tree structures. Tree terminology is generally derived from the terminology of family trees specifically, the type of family tree called a lineal chart. If every non-leaf node in a binary tree has nonempty left and right subtrees, the tree is termed a strictly binary tree. Or, to put it another way, all of the nodes in a strictly binary tree are of degree zero or two, never degree one. A complete binary tree of depth d is the strictly binary tree all of whose leaves are at level d.

Since all leaves in such a tree are at level d , the tree contains 2 d leaves and, therefore, 2 d - 1 internal nodes. An almost complete binary tree with N leaves that is not strictly binary has 2 N nodes.

There are two distinct almost complete binary trees with N leaves, one of which is strictly binary and one of which is not. There is only a single almost complete binary tree with N nodes.

This tree is strictly binary if and only if N is odd. If every non-leaf node in a binary tree has nonempty left and right subtrees, the tree is termed a strictly binary tree. Or, to put it another way, all of the nodes in a strictly binary tree are of degree zero or two, never degree one. A complete binary tree of depth d is the strictly binary tree all of whose leaves are at level d. Since all leaves in such a tree are at level d , the tree contains 2 d leaves and, therefore, 2 d - 1 internal nodes.

An almost complete binary tree with N leaves that is not strictly binary has 2 N nodes. There are two distinct almost complete binary trees with N leaves, one of which is strictly binary and one of which is not.

There is only a single almost complete binary tree with N nodes. This tree is strictly binary if and only if N is odd. For a complete or almost complete binary tree, storing the binary tree as an array may be a good choice.

One way to do this is to store the root of the tree in the first element of the array.