Tree and its terminologies

Slides:



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

Introduction to Trees Chapter 6 Objectives
Computer Science C++ High School Level By Guillermo Moreno.
Binary Tree Terminology Linear versus hierarchical data Tree – connected graph with no cycles Child Parent Descendant Sibling Ancestor Leaf vs. internal.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Binary Trees Chapter 6.
Lecture 06: Tree Structures Topics: Trees in general Binary Search Trees Application: Huffman Coding Other types of Trees.
CS261 Data Structures Trees Introduction and Applications.
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.
Binary Trees. Binary Tree Finite (possibly empty) collection of elements A nonempty binary tree has a root element The remaining elements (if any) are.
Topic 17 Introduction to Trees
Tree Data Structures.
Trees Dr. Andrew Wallace PhD BEng(hons) EurIng
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.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 4. Trees.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
2-3 Trees Extended tree.  Tree in which all empty subtrees are replaced by new nodes that are called external nodes.  Original nodes are called internal.
Data Structures TREES.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
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.
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.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
2/11/ IT 179 Recursive Definition of Tree Structures 1.Empty is a tree; the root is null 2.A node points to a finite number of the roots of some.
1 Trees What is a Tree? Tree terminology Why trees? What is a general tree? Implementing trees Binary trees Binary tree implementation Application of Binary.
Question 4 Tutorial 8. Part A Insert 20, 10, 15, 5,7, 30, 25, 18, 37, 12 and 40 in sequence into an empty binary tree
1 Trees. 2 Trees Trees. Binary Trees Tree Traversal.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 4. Trees.
Chapter 10 Trees © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
CSCE 210 Data Structures and Algorithms
Lecture 1 (UNIT -4) TREE SUNIL KUMAR CIT-UPES.
Binary Trees.
Recursive Definition of Tree Structures
CISC220 Fall 2009 James Atlas Lecture 13: Binary Trees.
Problems with Linked List (as we’ve seen so far…)
Binary Trees "The best time to plant a tree is twenty years ago. The second best time is now." -Chinese proverb Real programmmers always confuse Christmas.
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Objective: Understand Concepts related to trees.
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.
CHAPTER 4 Trees.
Tree data structure.
Binary Trees Lecture 36 Wed, Apr 21, /21/2018 Binary Trees.
Data Structures and Database Applications Binary Trees in C#
Depict the Tree Structure in a picture
TREES General trees Binary trees Binary search trees AVL trees
Binary Trees.
Trees and Binary Trees.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Tree data structure.
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Trees.
Heaps and the Heapsort Heaps and priority queues
Binary Trees.
Topic 18 Binary Trees "A tree may grow a thousand feet tall, but its leaves will return to its roots." -Chinese Proverb.
Data Structures: Trees and Binary Trees
Trees Definitions Implementation Traversals K-ary Trees
Trees (Part 1, Theoretical)
Binary Trees CS-2851 Dr. Mark L. Hornick.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Representing binary trees with lists
Binary Trees, Binary Search Trees
Binary Trees.
Tree.
Chapter 20: Binary Trees.
Binary Trees.
Trees.
NATURE VIEW OF A TREE leaves branches root. NATURE VIEW OF A TREE leaves branches root.
Presentation transcript:

Tree and its terminologies The root Ancestors a the links is directed, always pointing down 1 Descendants height of b = 4 b c 1 1 height of c = 1 2 leaf depth of d =2 Parent of e,f,g,h,i 2 d Children of d Siblings e f g h i 3 leaf leaf leaf Siblings j k Siblings m n k 4 leaf leaf leaf leaf leaf 6/3/2019 IT 279

More Terminologies In-degree: the number of links pointing to a node (always 1 or 0); the root is the only node with in-degree 0. 2. Out-degree: the number of link pointing out from a node; leaves are node with out-degree 0 3 . Degree of a tree (arity): the maximum out-degree of nodes in the tree a b c d e f g h i j k 6/3/2019 IT 279

Binary Tree (2 degree tree) 6/3/2019 Linked Lists Binary Tree (2 degree tree) data Data field Right and Left Children 2 Left child Right child 24 34 13 4 34 6/3/2019 IT 279

C++ : template<typename T> class BinaryTree { public: … private: struct Node { Node(T item, Node *left, Node *right): data(item), left(left), right(right) {}; T data; Node<T> *left; Node<T> *right; }; 6/3/2019 IT 279

A perfect-tree or complete tree is a perfect example for using array d1 d1 d2 d3 d2 d3 d7 d4 d4 d5 d6 d5 d6 d7 d8 d8 d9 d10 d11 d12 d13 d14 d15 d9 d10 complete tree full-tree (no single child) perfect-tree 24-1 6/3/2019 IT 279

a b g d h i j k c l m v w x y z f g h q i 6/3/2019 IT 279

Tree Implementation: linked lists  arrays 6/3/2019 Tree Implementation: linked lists  arrays Links data data field enough fields for pointers pointing the children Usually, we use the degree of the tree as the number of the pointer fields. Fixed, if the degree is small, e.g., binary tree (degree is 2). 6/3/2019 IT 279

a b g d h i j k c l m v w x y z f g h q i 6/3/2019 IT 279