1 / 17

Tree Concepts

Tree Concepts. A tree are very flexible, versatile and powerful non-liner data structure that consists of finite set of elements, called nodes , and a finite set of directed lines called branches , that connect the nodes. A tree is a data structure. It is used for storing files

malory
Download Presentation

Tree Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tree Concepts • A tree are very flexible, versatile and powerful non-liner data structure that consists of finite set of elements, called nodes, and a finite set of directed lines called branches, that connect the nodes. • A tree is a data structure. It is used for • storing files • compiler design • text processing • searching algorithms 1

  2. A starting node called root. • The rest of nodes can be split into T1, T2, -, Tn, which are subtrees of the root.

  3. Basic Terminology • Degree Of Node :- Number of sub trees for that node • A leaf :is any node with an outdegree of zero, that is, a node with no successors. • A node that is not a root or a leaf is known as an internal node. • A node is a parent if it has successors nodes; that is, if it has outdegree greater than zero. • A node with a predecessor is called a child. • A pathis a sequence of nodes in which each node is adjacent to the next node.

  4. A node 1 degree 3 children E C B siblings B, D D 2 E F H I J 3 G parent B ancestors A, D, H M 4 L K leaf height or depth tree = maximum level of any node in the tree = 4 degree of a tree = maximum of the degree of the nodes = 3

  5. When the branch is directed toward the node, it is indegreebranch. • When the branch is directed away from the node, it is an outdegreebranch. • If the tree is not empty, the first node is called the root. • Node degree=number of output paths for it. 6

  6. 7

  7. Binary Trees • A binary tree is a finite set of nodes that is either empty or consists of a root and two disjoint binary trees called the left subtree and the right subtree. • A binary tree can have no more than two descendents. In this section we discuss the properties of binary trees, four different binary tree traversals • Properties • Binary Tree Traversals • Expression Trees 9

  8. Binary Trees • A binary tree is a tree in which no node can have more than two subtrees; the maximum outdegree for a node is two. • In other words, a node can have zero, one, or two subtrees. • These subtrees are designated as the left subtree and the right subtree. 10

  9. 11

  10. A null tree is a tree with no nodes 12

More Related