Introduction Of Tree. Introduction A tree is a non-linear data structure in which items are arranged in sequence. It is used to represent hierarchical.

Slides:



Advertisements
Similar presentations
COSC2007 Data Structures II Chapter 10 Trees I. 2 Topics Terminology.
Advertisements

Introduction to Trees Chapter 6 Objectives
Data Structures: A Pseudocode Approach with C 1 Chapter 6 Objectives Upon completion you will be able to: Understand and use basic tree terminology and.
EC-211 DATA STRUCTURES LECTURE Tree Data Structure Introduction –The Data Organizations Presented Earlier are Linear in That Items are One After.
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
CHAPTER 12 Trees. 2 Tree Definition A tree is a non-linear structure, consisting of nodes and links Links: The links are represented by ordered pairs.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Trees.
Binary Trees Chapter 6.
Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras.
CHAPTER 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
COSC2007 Data Structures II
Trees. Introduction to Trees Trees are very common in computer science They come in different forms They are used as data representation in many applications.
CS Data Structures Chapter 5 Trees. Chapter 5 Trees: Outline  Introduction  Representation Of Trees  Binary Trees  Binary Tree Traversals 
Saturday, 04 Apr 2010 University of Palestine Computer Science II Trees.
12-CRS-0106 REVISED 8 FEB 2013 CSG2A3 ALGORITMA dan STRUKTUR DATA.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
Binary Trees. Binary Tree Finite (possibly empty) collection of elements A nonempty binary tree has a root element The remaining elements (if any) are.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
1 CSC 211 Data Structures Lecture 24 Dr. Iftikhar Azim Niaz 1.
Compiled by: Dr. Mohammad Omar Alhawarat
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
TREES. What is a tree ? An Abstract Data Type which emulates a tree structure with a set of linked nodes The nodes within a tree are organized in a hierarchical.
Data Structures TREES.
Review 1 Queue Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
Lecture - 10 on Data Structures. 6:05:57 PM Prepared by, Jesmin Akhter, Lecturer, IIT,JU.
Disusun Oleh : Budi Arifitama Pertemuan ke-8. Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms.
Introduction to Trees IT12112 Lecture 05 Introduction Tree is one of the most important non-linear data structures in computing. It allows us to implement.
Trees By P.Naga Srinivasu M.tech,(MBA). Basic Tree Concepts A tree consists of finite set of elements, called nodes, and a finite set of directed lines.
Discrete Mathematics Chapter 5 Trees.
Binary Tree 10/22/081. Tree A nonlinear data structure Contain a distinguished node R, called the root of tree and a set of subtrees. Two nodes n1 and.
M180: Data Structures & Algorithms in Java Trees & Binary Trees Arab Open University 1.
CMSC 341 Introduction to Trees. 2/21/20062 Tree ADT Tree definition –A tree is a set of nodes which may be empty –If not empty, then there is a distinguished.
Trees Dr. Yasir Ali. A graph is called a tree if, and only if, it is circuit-free and connected. A graph is called a forest if, and only if, it is circuit-free.
DATA STRUCTURE BS(IT)3rd. Tree An Introduction By Yasir Mustafa Roll No. BS(IT) Bahauddin Zakariya University, Multan.
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
Trees (Unit 7).
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
TREES General trees Binary trees Binary search trees AVL trees Balanced and Threaded trees.
Chapter 6 – Trees. Notice that in a tree, there is exactly one path from the root to each node.
DATA STRUCURES II CSC QUIZ 1. What is Data Structure ? 2. Mention the classifications of data structure giving example of each. 3. Briefly explain.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
TREES From root to leaf. Trees  A tree is a non-linear collection  The elements are in a hierarchical arrangement  The elements are not accessible.
Chapter 10 Trees © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Data Structures and Design in Java © Rick Mercer
Trees Chapter 15.
CSCE 210 Data Structures and Algorithms
Lecture 1 (UNIT -4) TREE SUNIL KUMAR CIT-UPES.
12. Graphs and Trees 2 Summary
Binary Trees "A tree may grow a thousand feet tall, but its leaves will return to its roots." -Chinese Proverb.
CMSC 341 Introduction to Trees.
Lecture 18. Basics and types of Trees
CHAPTER 4 Trees.
TREES General trees Binary trees Binary search trees AVL trees
Introduction to Trees IT12112 Lecture 05.
Trees and Binary Trees.
Data Structures: Trees and Binary Trees
CSE 373, Copyright S. Tanimoto, 2002 Binary Trees -
CMSC 202 Trees.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Trees.
CSE 373, Copyright S. Tanimoto, 2001 Binary Trees -
Tree.
Binary Trees.
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Introduction to Trees Chapter 6 Objectives
Presentation transcript:

Introduction Of Tree

Introduction A tree is a non-linear data structure in which items are arranged in sequence. It is used to represent hierarchical relationship existing amongst several data items. The graph theoretic definition of tree is: It is a finite set of one or more data items (nodes) such that. 1. There is a special data item called the root of the tree. 2. And its remaining data items are partitioned into number of mutually exclusive (disjoint) subsets, each of which is itself a tree. And they are called sub trees.

Introduction Another way we can say, A class of graphs that is acyclic is termed as trees. A tree is shown bellow:

Tree Terminology There are number of designed data item in a tree which is listed below: 1. Root 2. Node 3. Degree of a node 4. Degree of a tree 5. Terminal node 6. Non-terminal node

Tree Terminology 7. Siblings 8. Level 9. Edge 10. Path 11. Depth 12. Forest

Tree Terminology Root It is specially designed data item in a tree. It is the first in the hierarchical arrangement of data items. In the above tree, A is the root item. Node Each data item in a tree is called a node. It is the basic structure in a tree. It specifies the data information and links (branches) to other data items. There are 13 nodes in the above tree.

Tree Terminology Degree of a node It is the number of sub trees of a node in a given tree. In the above tree. The degree of node A is 3 The degree of node C is 1 The degree of node B is 2 The degree of node H is 0 The degree of node I is 3

Tree Terminology Degree of a tree It is the maximum degree of nodes in a given tree. In the above tree the node A has degree 3 and another node I is also having its degree 3. In all this value is the maximum. So, the degree of the above tree is 3.

Tree Terminology Terminal node A node with degree zero is called a terminal node or a leaf node. In the above tree, there are 7 terminal nodes. They are E, J, G, H, K, L and M. Non-terminal node Any node (except the root node) whose degree is not zero is called non-terminal node. Non-terminal nodes are the intermediate nodes in traversing the given tree from its root node to the terminal node (leaves). There are 5 non-terminal nodes.

Tree Terminology Siblings The children nodes of a given parent node are called siblings. They are also called brothers. In the above tree, E and F are siblings of parent node B. K, L and M are siblings of parent node I.

Tree Terminology Level The entire tree structure is level in such a way that the root node is always at level 0. Then, its immediate children are at level 1 and their immediate children are at level 2 and so on up to the terminal nodes.

Tree Terminology Edge It is a connecting line of two nodes. That is the line draw from one node to another node is called an edge. Path It is sequence of consecutive edges from the source node to the destination node. In the above tree the path between A and J is given by the node pairs. (A,B) (B,F) and (F,J)

Tree Terminology Depth It is the maximum level of any node in a given tree. In the above tree the root node A has the maximum level. That is the number of levels one can descend the tree from its root to the terminal nodes (leaves). The term height is also used to denote the depth.

Tree Terminology Forest It is a set of disjoint trees. In a given tree, if we remove its root node then it becomes a forest in the above tree, there is forest with three trees.

Type of Tree : Binary Tree A binary tree is finite set of data items which is either empty of consists of a single item called the root and two disjoint binary trees called the left sub tree and right sub tree. A binary tree is very important and the most commonly used non-linear data structure. In a binary tree the maximum degree of any node is at most two. That means, there may be zero degree node (empty tree) or a one degree node and two degree node.

Type of Tree : Binary Tree Show bellow binary tree consisting of 10 elements.

Type of Tree : Binary Tree In the above binary tree, A is the root of the tree. The left sub tree consists of the tree with root B. and the right sub tree consists of the tree with root C. Further B has its left sub tree with root D and right sub tree with root E. Similarly, C has its left sub tree with root F and its right sub tree with root G.

Type of Tree : Binary Tree In the next level, D has an empty left sub tree and its right sub tree with root H. F has neither its left sub tree nor right sub tree. Similarly, G as its root and has an empty right sub tree.

Type of Tree : Strictly Binary trees If every non-terminal node in a binary tree consists of non empty left sub tree and right sub tree(that means exactly two child), then a tree is called strictly binary tree.

Type of Tree : Strictly Binary trees

Type of Tree : Complete Binary Tree A binary tree with n nodes and of depth d is a strictly binary tree all of whose terminal nodes are at level d. In a complete binary tree, there is exactly one node at level 0, two node at level 1, and four nodes at level 2 and so on. That means 2 m nodes at each level. So, level 0 has 2 0 nodes that mean only one root. Next level 1 has 2 1 nodes that mean two nodes; again next level 2 has 2 2 nodes that mean 4 nodes.

Type of Tree : Complete Binary Tree

Type of Tree : Full Binary Tree A binary tree is a full binary tree if it contains the maximum possible number of nodes in all levels. Next slide figure a full binary tree of height 2. In a full binary tree, each node has two children or no child at all. The total number of nodes in a full binary tree of height h is 2 h+1 -1 considering the root at level 0.

Type of Tree : Full Binary Tree

It can be calculated by adding the number of nodes of each level as in the following equation: 2 h+1 -1 In our example h=2, so =8-1=7 nodes in the full binary tree.

Type of Tree : Extended Binary Trees A binary tree T is said to be extended binary tree if each node N has either 0 or 2 children. In such a case the nodes with 2 children are called internal nodes, and the nodes with 0 children are called external nodes. Sometimes the nodes are distinguished in diagrams by using circles for internal nodes and squares for external nodes.

Type of Tree : Extended Binary Trees