In a graph-theoretic sense, a tree is a connected, undirected, acyclic graph. In a data structure sense, a tree is accessed beginning at a node distinguished as the root. Every node in the tree is either a leaf (a node with no children/descendants) or an interior node.
In a formal sense, a tree is either
A binary tree is a tree in which each node has at most 2 children. A binary search tree (BST) is a binary tree in which the values stored in the left subtree are less than the value stored at the node and the values stored in the right subtree are greater than the value stored at the node. A BST has search performance of O(log n) assuming it's balanced.
Other terms to be aware of are
Some interesting things to consider:
The code for "standard" binary tree operations in C is not that
different from what you'd write in Java. We've provided code that
implements most of the standard ops in b-tree-code.c. I encourage you to take a look
at the printTree
function which makes use of a
non-standard traversal of the tree to print a "reasonable"
approximation of the tree rotated 90 degrees.