More Trees Discrete Structures (CS 173)

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

S. Sudarshan Based partly on material from Fawzi Emad & Chau-Wen Tseng
Tree Data Structures &Binary Search Tree 1. Trees Data Structures Tree  Nodes  Each node can have 0 or more children  A node can have at most one parent.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
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.
GRAMMAR & PARSING (Syntactic Analysis) NLP- WEEK 4.
CS 171: Introduction to Computer Science II
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
1 Introduction to Computability Theory Lecture7: The Pumping Lemma for Context Free Languages Prof. Amos Israeli.
CS2420: Lecture 13 Vladimir Kulyukin Computer Science Department Utah State University.
Binary Tree Terminology Linear versus hierarchical data Tree – connected graph with no cycles Child Parent Descendant Sibling Ancestor Leaf vs. internal.
A tree is a simple graph satisfying: if v and w are vertices and there is a path from v to w, it is a unique simple path. a b c a b c.
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
CSC 2300 Data Structures & Algorithms February 6, 2007 Chapter 4. Trees.
Version TCSS 342, Winter 2006 Lecture Notes Trees Binary Trees Binary Search Trees.
1 CSCI 2400 section 3 Models of Computation Instructor: Costas Busch.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
CS 3610 Midterm Review.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
CS-2852 Data Structures LECTURE 11 Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
Data Structures TREES.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.
Rudiments of Trees a Joshua presentation DATA STRUCTURES.
Discrete Mathematics Chapter 5 Trees.
Graphs & Trees Intro2CS – week General Graphs Nodes (Objects) can have more than one reference. Example: think of implementing a Class “Person”
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
DATA STRUCTURE BS(IT)3rd. Tree An Introduction By Yasir Mustafa Roll No. BS(IT) Bahauddin Zakariya University, Multan.
Trees. What is a tree? You know…  tall  green  leafy  possibly fruit  branches  roots  I’m sure you’ve seen them.
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
CH 7 : TREE ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY.
Foundation of Computing Systems Lecture 4 Trees: Part I.
MA/CSSE 473 Day 30 B Trees Dynamic Programming Binomial Coefficients Warshall's algorithm No in-class quiz today Student questions?
Graphs and Trees Mathematical Structures for Computer Science Chapter 5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraphs and Trees.
This Lecture Intro to Tree ADT Terminologies Tree Types Tree Traversals Binary Search Tree Expression Trees.
1 Lecture 14: Trees & Insertion Sort CompSci 105 SS 2006 Principles of Computer Science.
03/05/13 More Induction Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Artist: Frank.
Chapter 6 – Trees. Notice that in a tree, there is exactly one path from the root to each node.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
03/12/13 Trees and CFGs Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.
CSCE 210 Data Structures and Algorithms
Lecture 1 (UNIT -4) TREE SUNIL KUMAR CIT-UPES.
Fundamentals of Programming II Introduction to Trees
Recursive Objects (Part 4)
Trees.
CISC220 Fall 2009 James Atlas Lecture 13: Binary Trees.
Tree.
Objective: Understand Concepts related to trees.
Section 8.1 Trees.
CHAPTER 4 Trees.
Trees and Binary Trees.
(2,4) Trees (2,4) Trees 1 (2,4) Trees (2,4) Trees
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
CS200: Algorithm Analysis
CSCI-2400 Models of Computation.
Trees (Part 1, Theoretical)
Lecture 36 Section 12.2 Mon, Apr 23, 2007
A Introduction to Computing II Lecture 13: Trees
Trees Construction Paths Height/Depth Ordered Trees Traversals
Chapter 20: Binary Trees.
Goals Design decisions Design Insertion
7.1 Trees.
Tutorial 2 - Daniel Razavi
Trees.
Presentation transcript:

More Trees Discrete Structures (CS 173) 03/14/13 Magritte Discrete Structures (CS 173) Derek Hoiem, University of Illinois

Last class: trees and CFGs Trees are a special graph with root and no cycles, with many uses Sorting, clustering, finding similar values Decision tree: machine learning, modeling choices Parse trees: representing hierarchical structures Context free grammars: generate parse trees Proofs on trees: split at root, use inductive hypothesis on subtrees headed by the root’s children

Tree terminology Nodes: root, internal, leaf, level, tree height Relations: parent/child/sibling, ancestor/descendant root level = 0 parent, child level = 1 internal subtree level = 2 level = 3 leaves

This lecture: more trees Recursion trees for illustrating computation in recursive functions Another tree proof

Useful formulas 𝑚 𝑎 𝑏 = 𝑚 𝑎𝑏 𝑚 𝑎+𝑏 = 𝑚 𝑎 𝑚 𝑏 2 log 2 𝑛 =𝑛 𝑘=0 𝑛 𝑟 𝑘 = 1− 𝑟 𝑛+1 1−𝑟 𝑘=𝑚 𝑛 𝑟 𝑘 = 𝑟 𝑚 − 𝑟 𝑛+1 1−𝑟 𝑘=𝑖 𝑛 𝑘 = 𝑛(𝑛+1) 2 𝑘=0 𝑛 2 𝑘 = 𝑘=1 𝑛 2 𝑘 = 𝑘=0 𝑛 2 −2𝑘 = 𝑘=0 𝑛 2 𝑘+2 = 𝑚 𝑎 𝑏 = 𝑚 𝑎𝑏 𝑚 𝑎+𝑏 = 𝑚 𝑎 𝑚 𝑏 2 log 2 𝑛 =𝑛 log 𝑎 (𝑏) = log 2 (𝑏)/ log 2 𝑎 2 log 4 (𝑛)+2 =

Recursion trees 𝑇 1 =𝑐 𝑇 𝑛 =2𝑇 𝑛/2 +𝑛 cost of input cost of subproblem split in 2 How many levels before base case? Sum of values in each level? How many leaf nodes? Total cost = sum of leaf costs + sum of internal costs:

Recursion trees 𝑇 1 =𝑐 𝑇 𝑛 =2𝑇 𝑛−1 +𝑑

Recursion trees A 1 =𝑐 A 𝑛 =4𝐴 𝑛/2 +𝑛

Tree induction proof If 𝑇 is a binary tree with root 𝑟, then its rank is (a) 0 if 𝑟 has no children (b) 1+𝑞 if 𝑟 has two children, both with rank 𝑞 (c) otherwise, the maximum rank of any of the children

Tree induction proof If 𝑇 is a binary tree with root 𝑟, then its rank is (a) 0 if 𝑟 has no children (b) 1+𝑞 if 𝑟 has two children, both with rank 𝑞 (c) otherwise, the maximum rank of any of the children Claim: A tree with rank 𝑞 has at least 2 𝑞 leaves.

Have a great break!