Definition
A binary search tree is organized, as the name suggests, in a binary tree. Each node is an object. In addition to a key field and satellite data, left, right, and p fields that point to the nodes corresponding to its left child, its right child, and its parent, respectively. If a child or the parent is missing, the appropriate field contains the value NIL.
Property
let x be a node in a binary search tree. If y is a node in the left subtree of x, then key[y] ≤ key[x]. If y is a node in the right subtree of x, then key[x] ≤ key[y].
The binary-search-tree property allows us to print out all the keys in a binary search tree in sorted order by inorder tree walk.
Theorem If x is the root of an n-node subtree, then the call INORDER-TREE-WALK(x) takes θ(n) time.
Proof: Let T(n) denote the time taken by INORDER-TREE-WALK when it is called on the root of an n-node subtree.
INORDER-TREE-WALK takes a small, constant amount of time on an empty subtree and so T(0) =c for some positive constant c.
For n > 0, suppose that INORDER-TREE-WALK is called on a node x whose left subtree has k nodes and whose right subtree has n-k-1 nodes. The time to perform INORDER-TREE-WALK(x) is