Page 200 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 200

Unit 12: Introduction to Trees




          Let us discuss the terminology related to trees.                                      Notes
               A node is a structure which may contain a value, a condition, or represent a separate data
               structure (which could be a tree of its own). Each node in a tree has zero or more child
               nodes, which are below it in the tree (by convention, trees grow down, not up as they do
               in nature). A node that has a child is called the child’s parent node (or ancestor node, or
               superior). A node has at most one parent.
               Nodes that do not have any children are called leaf nodes. They are also referred to as
               terminal nodes.
               The height of a node is the length of the longest downward path to a leaf from that node.
               The height of the root is the height of the tree. The depth of a node is the length of the path
               to its root (i.e. its root path). This is commonly needed in the manipulation of the various
               self balancing trees, AVL Trees in particular. Conventionally, the value -1 corresponds to
               a subtree with no nodes, whereas zero corresponds to a subtree with one node.
               The topmost node in a tree is called the root node. Being the topmost node, the root node
               will not have parents. It is the node at which operations on the tree commonly begin
               (although some algorithms begin with the leaf nodes and work up ending at the root). All
               other nodes can be reached from it by following edges or links. (In the formal definition,
               each such path is also unique). In diagrams, it is typically drawn at the top.




             Notes  In some trees, such as heaps, the root node has special properties. Every node in a
            tree can be seen as the root node of the subtree rooted at that node.
               An internal node or inner node is any node of a tree that has child nodes and is thus not a
               leaf node.

               A subtree of a tree T is a tree consisting of a node in T and all of its descendants in T. (This
               is different from the formal definition of subtree used in graph theory.) The subtree
               corresponding to the root node is the entire tree; the subtree corresponding to any other
               node is called a proper subtree (in analogy to the term proper subset).


                 Example: Consider the tree given below.

                                          Figure 12.1: Tree





















          Source: http://datastructures.itgo.com/trees/concept.htm




                                           LOVELY PROFESSIONAL UNIVERSITY                                   193
   195   196   197   198   199   200   201   202   203   204   205