Week 11 - Friday.  What did we talk about last time?  Graph isomorphism  Trees.

Slides:



Advertisements
Similar presentations
Chapter 11 Trees Graphs III (Trees, MSTs) Reading: Epp Chp 11.5, 11.6.
Advertisements

Trees Chapter 11.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Graphs III (Trees, MSTs) (Chp 11.5, 11.6)
Week 12 - Monday.  What did we talk about last time?  Trees  Graphing functions.
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.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
1 Section 9.1 Introduction to Trees. 2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph:
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
The Growth of Functions
Graphs and Trees This handout: Trees Minimum Spanning Tree Problem.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
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.
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Binary Trees Chapter 6.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Fall 2014 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Chapter 5 Algorithm Analysis 1CSCI 3333 Data Structures.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
Week 15 - Friday.  What did we talk about last time?  Review second third of the course.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Relations And Functions. A relation from non empty set A to a non empty set B is a subset of cartesian product of A x B. This is a relation The domain.
CS Data Structures Chapter 5 Trees. Chapter 5 Trees: Outline  Introduction  Representation Of Trees  Binary Trees  Binary Tree Traversals 
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
Multiway Trees. Trees with possibly more than two branches at each node are know as Multiway trees. 1. Orchards, Trees, and Binary Trees 2. Lexicographic.
Week 12 - Friday.  What did we talk about last time?  Asymptotic notation.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
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.
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Week 12 - Wednesday.  What did we talk about last time?  Asymptotic notation.
O, , and  Notations Lecture 39 Section 9.2 Wed, Mar 30, 2005.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
B + -Trees. Motivation An AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows that most operations.
Discrete Structures Trees (Ch. 11)
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
O -Notation April 23, 2003 Prepared by Doug Hogan CSE 260.
Chapter 9 Efficiency of Algorithms. 9.1 Real Valued Functions.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.
Discrete Mathematics Chapter 5 Trees.
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.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Week 11 - Friday.  What did we talk about last time?  Paths and circuits  Matrix representation of graphs.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Section10.1: Introduction to Trees
CSE 373 Data Structures Lecture 7
Chapter 7 Absolute Value and Reciprocal Funtions
Applied Discrete Mathematics Week 15: Trees
12. Graphs and Trees 2 Summary
Introduction to Trees Section 11.1.
B+ Tree.
Lecture 18. Basics and types of Trees
Advanced Algorithms Analysis and Design
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
CMSC 202 Trees.
And the Final Subject is…
Lecture 44 Section 9.2 Mon, Apr 23, 2007
NATURE VIEW OF A TREE leaves branches root. NATURE VIEW OF A TREE leaves branches root.
Presentation transcript:

Week 11 - Friday

 What did we talk about last time?  Graph isomorphism  Trees

 You are the despotic ruler of an ancient empire  Tomorrow is the 25th anniversary of your reign  You have 1,000 bottles of wine you were planning to open for the celebration  Your Grand Vizier uncovered a plot to murder you:  10 years ago, a rebel worked in the vineyard that makes your wine  He poisoned one of the 1,000 bottles you are going to serve tonight and has been waiting for revenge  The rebel died an accidental death, and his papers revealed his plan, but not which bottle was poisoned  The poison exhibits no symptoms until death  Death occurs within ten to twenty hours after consuming even the tiniest amount of poison  You have over a thousand slaves at your disposal and just under 24 hours to determine which single bottle is poisoned  You have a few hundred prisoners, sentenced to death  Can you use just the prisoners and risk no slaves?  If so, what's the smallest number of prisoners you can risk and still be sure to find the bottle?

 A grammar for a formal language (such as we will discuss next week or the week after) is made up of rules that allow non- terminals to be turned into other non-terminals or terminals  For example: 1.  2.  | 3.  4.  a | an | the 5.  funky 6.  DJ | beat 7.  plays | spins  Make a parse tree corresponding to the sentence, "The DJ plays a funky beat"

 Any tree with more than one vertex has at least one vertex of degree 1  If a vertex in a tree has degree 1 it is called a terminal vertex (or leaf)  All vertices of degree greater than 1 in a tree are called internal vertices (or branch vertices)

 For any positive integer n, a tree with n vertices must have n – 1 edges  Prove this by mathematical induction  Hint: Any tree with 2 or more nodes has a vertex of degree 1. What happens when you remove that vertex?

 In a rooted tree, one vertex is distinguished and called the root  The level of a vertex is the number of edges along the unique path between it and the root  The height of a rooted tree is the maximum level of any vertex of the tree  The children of any vertex v in a rooted tree are all those nodes that are adjacent to v and one level further away from the root than v  Two distinct vertices that are children of the same parent are called siblings  If w is a child of v, then v is the parent of w  If v is on the unique path from w to the root, then v is an ancestor of w and w is a descendant of v

 Consider the following tree, rooted at 0  What is the level of 5?  What is the level of 0?  What is the height of this tree?  What are the children of 3?  What is the parent of 2?  What are the siblings of 8?  What are the descendants of 3?

 A binary tree is a rooted tree in which every parent has at most two children  Each child is designated either the left child or the right child  In a full binary tree, each parent has exactly two children  Given a parent v in a binary tree, the left subtree of v is the binary tree whose root is the left child of v  Ditto for right subtree

 As we all know from data structures, a binary tree can be used to make a data structure that is efficient for insertions, deletions, and searches  But, it doesn't stop there!  We can represent binary arithmetic with a binary tree  Make a binary tree for the expression ((a – b)∙c) + (d/e)  The root of each subtree is an operator  Each subtree is either a single operand or another expression

 If k is a positive integer and T is a full binary tree with k internal vertices, then T has a total of 2k + 1 vertices and has k + 1 terminal vertices  Prove it!  Hint: Induction isn't needed. We just need to relate the number of non-terminal nodes to the number of terminal nodes

 If T is a perfect binary tree with height h, then it has 2 h+1 – 1 vertices  Prove it using induction!

 If T is a binary tree with t terminal vertices and height h, then t  2 h  Prove it using strong induction on the height of the tree  Hint: Consider cases where the root of the tree has 1 child and 2 children separately

 I am assuming that you have been graphing functions since about 6 th or 7 th grade  Still, the formal definition of a graph of a function is:  Let f be a real-valued function of a real variable  The graph of f is the set of all points (x, y) in the Cartesian coordinate plane such that x is in the domain of f and y = f(x)

 In computer science, we are often interested in power functions of x written p a (x) where p a (x) = x a where x and a are nonnegative  Power functions are the building blocks of polynomial functions  Graph the following on the same coordinate axes p0p0  p 1/2 p1p1 p2p2

 Recall the definition of the floor of x:   x  = the largest integer that is less than or equal to x  Graph f(x) =  x   Defining functions on integers instead of real values affects their graphs a great deal  Graph p 1 (x) = x, x  R  Graph f(n) = n, n  N

 There is a strong visual (and of course mathematical) correlation a function that is the multiple of another function  Examples:  g(x) = x + 2  2g(x) = 2x + 4  Given f graphed below, sketch 2f

 Consider the absolute value function  f(x) = |x|  Left of the origin it is constantly decreasing  Right of the origin it is constantly increasing

 We say that f is decreasing on the set S iff for all real numbers x 1 and x 2 in S, if x 1 f(x 2 )  We say that f is increasing on the set S iff for all real numbers x 1 and x 2 in S, if x 1 < x 2, then f(x 1 ) < f(x 2 )  We say that f is an increasing (or decreasing) function iff f is increasing (or decreasing) on its entire domain  Clearly, a positive multiple of an increasing function is increasing  Virtually all running time functions are increasing functions

Student Lecture

 Mathematicians worry about the growth of various functions  They usually express such things in terms of limits, maybe with derivatives  We are focused primarily on functions that bound running time spent and memory consumed  We just need a rough guide  We want to know the order of the growth

 Let f and g be real-valued functions defined on the same set of nonnegative real numbers  f is of order at least g, written f(x) is  (g(x)), iff there is a positive A  R and a nonnegative a  R such that  A|g(x)| ≤ |f(x)| for all x > a  f is of order at most g, written f(x) is O(g(x)), iff there is a positive B  R and a nonnegative b  R such that  |f(x)| ≤ B|g(x)| for all x > b  f is of order g, written f(x) is  (g(x)), iff there are positive A, B  R and a nonnegative k  R such that  A|g(x)| ≤ |f(x)| ≤ B|g(x)| for all x > k

 Express the following statements using appropriate notation:  10|x 6 | ≤ |17x 6 – 45x 3 + 2x + 8| ≤ 30|x 6 |, for x > 2    Justify the following:  is  (  x)

 Let f and g be real-valued functions defined on the same set of nonnegative real numbers 1. f(x) is  (g(x)) and f(x) is O(g(x)) iff f(x) is  (g(x)) 2. f(x) is  (g(x)) iff g(x) is O(f(x)) 3. f(x) is  (f(x)), f(x) is O(f(x)), and f(x) is  (f(x)) 4. If f(x) is O(g(x)) and g(x) is O(h(x)) then f(x) is O(h(x)) 5. If f(x) is O(g(x)) and c is a positive real, then c  f(x) is O(g(x)) 6. If f(x) is O(h(x)) and g(x) is O(k(x)) then f(x) + g(x) is O(G(x)) where G(x) = max(|h(x)|,|k(x)|) for all x 7. If f(x) is O(h(x)) and g(x) is O(k(x)) then f(x)g(x) is O(h(x)k(x))

 If 1 < x, then  x < x 2  x 2 < x 3 ……  So, for r, s  R, where r 1,  x r < x s  By extension, x r is O(x s )

 Prove a  bound for g(x) = (1/4)(x – 1)(x + 1) for x  R  Prove that x 2 is not O(x)  Hint: Proof by contradiction

 Let f(x) be a polynomial with degree n  f(x) = a n x n + a n-1 x n-1 + a n-2 x n-2 … + a 1 x + a 0  By extension from the previous results, if a n is a positive real, then  f(x) is O(x s ) for all integers s  n  f(x) is  (x r ) for all integers r ≤ n  f(x) is  (x n )  Furthermore, let g(x) be a polynomial with degree m  g(x) = b m x m + b m-1 x m-1 + b m-2 x m-2 … + b 1 x + b 0  If a n and b m are positive reals, then  f(x)/g(x) is O(x c ) for real numbers c > n - m  f(x)/g(x) is not O(x c ) for all integers c > n - m  f(x)/g(x) is  (x n - m )

 More on asymptotic notation

 Keep reading Chapter 11  Keep working on Assignment 9  Due next Friday