Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.

Slides:



Advertisements
Similar presentations
Introduction to Trees Chapter 6 Objectives
Advertisements

Binary Trees Chapter 6. Linked Lists Suck By now you realize that the title to this slide is true… By now you realize that the title to this slide is.
CS2420: Lecture 13 Vladimir Kulyukin Computer Science Department Utah State University.
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
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.
Trees CMSC 433 Chapter 8.1 Nelson Padua-Perez Bill Pugh.
Trees Chapter 23 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
A Binary Search Tree Implementation Chapter 25 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Chapter 9 contd. Binary Search Trees Anshuman Razdan Div of Computing Studies
Marc Smith and Jim Ten Eyck
Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras.
Binary Tree. Binary Trees – An Informal Definition A binary tree is a tree in which no node can have more than two children Each node has 0, 1, or 2 children.
Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important.
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.
Chapter 11 A Trees. © 2004 Pearson Addison-Wesley. All rights reserved 11 A-2 Terminology A tree consists of vertices and edges, –An edge connects to.
COSC2007 Data Structures II
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
CS Data Structures Chapter 15 Trees Mehmet H Gunes
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 10: Trees Data Abstraction & Problem Solving with C++
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
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.
Computer Science: A Structured Programming Approach Using C Trees Trees are used extensively in computer science to represent algebraic formulas;
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of CHAPTER 12: Multi-way Search Trees Java Software Structures: Designing.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Foundation of Computing Systems Lecture 4 Trees: Part I.
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
A Binary Search Tree Implementation Chapter 25 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Chapter 10 Trees © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Trees Chapter 15.
CSCE 210 Data Structures and Algorithms
Trees Chapter 11 (continued)
Trees Chapter 11 (continued)
Binary search tree. Removing a node
CS 302 Data Structures Trees.
Chapter 11: Multiway Search Trees
AVL DEFINITION An AVL tree is a binary search tree in which the balance factor of every node, which is defined as the difference between the heights of.
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Tree.
Csc 2720 Instructor: Zhuojun Duan
Section 8.1 Trees.
External Methods Chapter 15 (continued)
ITEC 2620M Introduction to Data Structures
Ch. 11 Trees 사실을 많이 아는 것 보다는 이론적 틀이 중요하고, 기억력보다는 생각하는 법이 더 중요하다.
8.2 Tree Traversals Chapter 8 - Trees.
Chapter 17 Linked Lists.
Chapter 19 Binary Search Trees.
Chapter 4 Inheritance.
Chapter 6 Transform and Conquer.
Chapter 14 Graphs and Paths.
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
Trees (Part 1, Theoretical)
CSE 373, Copyright S. Tanimoto, 2002 Binary Trees -
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Trees Chapter 10.
Trees.
Chapter 5 Algorithm Analysis.
CSE 373, Copyright S. Tanimoto, 2001 Binary Trees -
Chapter 20: Binary Trees.
B.Ramamurthy Chapter 9 CSE116A,B
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Chapter 2 Reference Types.
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved

Terminology Definition of a general tree Definition of a binary tree A general tree T is a set of one or more nodes such that T is partitioned into disjoint subsets: A single node r, the root Sets that are general trees, called subtrees of r Definition of a binary tree A binary tree is a set T of nodes such that either T is empty, or T is partitioned into three disjoint subsets: Two possibly empty sets that are binary trees, called left and right subtrees of r © 2011 Pearson Addison-Wesley. All rights reserved

Terminology Figure 11-4 Binary trees that represent algebraic expressions © 2011 Pearson Addison-Wesley. All rights reserved

Terminology A binary search tree A binary tree that has the following properties for each node n n’s value is greater than all values in its left subtree TL n’s value is less than all values in its right subtree TR Both TL and TR are binary search trees Figure 11-5 A binary search tree of names © 2011 Pearson Addison-Wesley. All rights reserved

Terminology The height of trees Level of a node n in a tree T If n is the root of T, it is at level 1 If n is not the root of T, its level is 1 greater than the level of its parent Height of a tree T defined in terms of the levels of its nodes If T is empty, its height is 0 If T is not empty, its height is equal to the maximum level of its nodes © 2011 Pearson Addison-Wesley. All rights reserved

Terminology Figure 11-6 Binary trees with the same nodes but different heights © 2011 Pearson Addison-Wesley. All rights reserved

Terminology Full, complete, and balanced binary trees A full binary tree of height h is a binary tree in which every node of level less than h has 2 children each. Figure 11-7 A full binary tree of height 3 © 2011 Pearson Addison-Wesley. All rights reserved

Terminology Complete binary trees A complete binary tree is a binary tree in which every level, except the last, is completely filled, and all nodes are as far left as possible. A binary tree T of height h is complete if All nodes at level h – 2 and above have two children each, and When a node at level h – 1 has children, all nodes to its left at the same level have two children each, and When a node at level h – 1 has one child, it is a left child Figure 11-8 A complete binary tree © 2011 Pearson Addison-Wesley. All rights reserved