Tree Representations Mathematical structure An edge A leaf The root A node.

Slides:



Advertisements
Similar presentations
Mathematical Preliminaries
Advertisements

DictionaryADT and Trees. Overview What is the DictionaryADT? What are trees? Implementing DictionaryADT with binary trees Balanced trees DictionaryADT.
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
Binary Trees A binary tree is made up of a finite set of nodes that is either empty or consists of a node called the root together with two binary trees,
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Binary Tree Properties & Representation. Minimum Number Of Nodes Minimum number of nodes in a binary tree whose height is h. At least one node at each.
Transforming Infix to Postfix
Chapter 9 contd. Binary Search Trees Anshuman Razdan Div of Computing Studies
1 Section 9.2 Tree Applications. 2 Binary Search Trees Goal is implementation of an efficient searching algorithm Binary Search Tree: –binary tree in.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
P p Chapter 10 has several programming projects, including a project that uses heaps. p p This presentation shows you what a heap is, and demonstrates.
Fall 2005Costas Busch - RPI1 Mathematical Preliminaries.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
5.2 Trees  A tree is a connected graph without any cycles.
CPSC 252 Binary Heaps Page 1 Binary Heaps A complete binary tree is a binary tree that satisfies the following properties: - every level, except possibly.
Discrete Mathematics Chapter 5 Trees.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
1Computer Sciences. 2 HEAP SORT TUTORIAL 4 Objective O(n lg n) worst case like merge sort. Sorts in place like insertion sort. A heap can be stored as.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
2 Binary Heaps What if we’re mostly concerned with finding the most relevant data?  A binary heap is a binary tree (2 or fewer subtrees for each node)
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.
"Teachers open the door, but you must enter by yourself. "
Heap Chapter 9 Objectives Define and implement heap structures
Lecture 1 (UNIT -4) TREE SUNIL KUMAR CIT-UPES.
AA Trees.
Data Structures Michael J. Watts
Data Structures and Algorithms for Information Processing
Recursive Objects (Part 4)
Chapter 5 : Trees.
CS 367 – Introduction to Data Structures
Multiway search trees and the (2,4)-tree
Binary Search Tree Chapter 10.
CS 2511 Fall 2014 Binary Heaps.
Trees Another Abstract Data Type (ADT)
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Lecture 22 Binary Search Trees Chapter 10 of textbook
CMSC 341 Introduction to Trees.
O(lg n) Search Tree Tree T is a search tree made up of n elements: x0 x1 x2 x3 … xn-1 No function (except transverse) takes more than O(lg n) in the.
Tree data structure.
CS223 Advanced Data Structures and Algorithms
Data Structures Balanced Trees CSCI
7/23/2009 Many thanks to David Sun for some of the included slides!
Chapter 8 – Binary Search Tree
Tree data structure.
Search Sorted Array: Binary Search Linked List: Linear Search
Trees Another Abstract Data Type (ADT)
Data Structures: Trees and Binary Trees
Trees Definitions Implementation Traversals K-ary Trees
"Teachers open the door, but you must enter by yourself. "
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Trees Another Abstract Data Type (ADT)
A Robust Data Structure
Binary Search Trees A special case of a Binary Tree
Binary Heaps What if we’re mostly concerned with finding the most relevant data? A binary heap is a binary tree (2 or fewer subtrees for each node) A heap.
Mathematical Preliminaries
Representing binary trees with lists
Copyright ©2012 by Pearson Education, Inc. All rights reserved
A Heap Implementation Chapter 26 Adapted from Pearson Education, Inc.
Binary Tree Properties & Representation
Tree.
Important Problem Types and Fundamental Data Structures
Red-Black Implementation of 2-3 Trees
OPIM 915 Fall 2010 Data Structures 23-38,
Tree and its terminologies
Heaps Chapter 6 Section 6.9.
Tutorial 2 - Daniel Razavi
Heaps.
Heaps Section 6.4, Pg. 309 (Section 9.1).
Presentation transcript:

Tree Representations Mathematical structure An edge A leaf The root A node

Tree Representations The number of edges = number of nodes - 1

Tree Representations The number of edges = number of nodes – 1 Let T(n) be the number of edges in tree with n nodes True for the case of 1 node T(1) = 0

Tree Representations The number of edges = number of nodes - 1 Suppose it's true for k nodes T(k) = k-1

Tree Representations The number of edges = number of nodes - 1 Then adding a node also adds an edge T(k+1) = T(k)+1 = k

Tree Representations If (always) a tree of fewer nodes is made a child of the root of a larger tree, then no tree will have a height greater than or equal to h unless it has at least 2 h nodes.

Tree Representations If (always) a tree of fewer nodes is made a child of the root of a larger tree, then no tree will have a height greater than or equal to h unless it has at least 2 h nodes. For h=0, number of nodes is 1 so hypothesis is true

Tree Representations If (always) a tree of fewer nodes is made a child of the root of a larger tree, then no tree will have a height greater than or equal to h unless it has at least 2 h nodes. For h>0, suppose true, then T obtained from tree of height h-1 and tree of fewer nodes than that one. By hypothesis, number of nodes of first is ≥ 2 h-1, of second ≥ 2 h-1 so total ≥ 2 h. height h-1, # nodes ≥ 2 h-1 T T 1 2 height h, # nodes ≥ 2 h-1 because this is the larger tree.

Tree Representations Matrix representation: rows indexed on nodes, columns also

Tree Representations Adjacency list representation: 0 : : : : :... Could be implemented with arrays or with linked lists

Tree Representations Binary tree representation: 3 tail root NULL 4 rghtnext leftnext 34 NULL 14 NULL 5 lefttree rghttree