Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006.

Slides:



Advertisements
Similar presentations
Lecture & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection.
Advertisements

Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Recursive Definitions and Structural Induction
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
Induction and recursion
Self-Reference - Induction Cmput Lecture 7 Department of Computing Science University of Alberta ©Duane Szafron 1999 Some code in this lecture is.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 9Feb 10,
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
This material in not in your text (except as exercises) Sequence Comparisons –Problems in molecular biology involve finding the minimum number of edit.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L18 (Chapter 23) Algorithm.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Induction and recursion
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 9b: Mathematical Induction - part 2.
Mathematical Maxims and Minims, 1988
Matthew Bowling Euler’s Theorem Mathfest Spring ‘15.
Sequences and Series (T) Students will know the form of an Arithmetic sequence.  Arithmetic Sequence: There exists a common difference (d) between each.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Chapter 6 Mathematical Induction
Discrete Mathematics, 1st Edition Kevin Ferland
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Mathematical Induction I Lecture 4: Sep 16. This Lecture Last time we have discussed different proof techniques. This time we will focus on probably the.
2.1 Use Inductive Reasoning Describe patterns and use inductive reasoning skills.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
(CSC 102) Lecture 23 Discrete Structures. Previous Lecture Summery  Sequences  Alternating Sequence  Summation Notation  Product Notation  Properties.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
EXAMPLE 1 Describe a visual pattern Describe how to sketch the fourth figure in the pattern. Then sketch the fourth figure. SOLUTION Each circle is divided.
2.1 Use Inductive Reasoning
1 INFO 2950 Prof. Carla Gomes Module Induction Rosen, Chapter 4.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Inductive Proofs and Inductive Definitions Jim Skon.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Mathematical Induction
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Section 2.3 Mathematical Induction. First Example Investigate the sum of the first n positive odd integers. 1= ____ 1 + 3= ____ = ____
Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach a particular.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Mathematical Induction I Lecture 19 Section 4.2 Mon, Feb 14, 2005.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
(Proof By) Induction Recursion
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
Induction and recursion
Use mathematical induction to prove that the formula is true for all natural numbers m. {image} Choose the first step of the proof from the following:
Chapter 5 Induction and Recursion
Proofs, Recursion and Analysis of Algorithms
Notes 9.5 – Mathematical Induction
Induction and recursion
Follow me for a walk through...
CSE 373 Data Structures and Algorithms
Mathematical Induction I
Mathematical Induction
Induction Chapter
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction
Counting Elements of Disjoint Sets: The Addition Rule
Application: Efficiency of Algorithms II
Mathematical Induction
Mathematical Induction II
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction II
Presentation transcript:

Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006

Example: Binary Search Trees In a complete binary search tree of depth n - 1, (n rows) what is the average number of comparisons required to locate an element? (Assuming all positions are equally likely.) Analysis Elements in row 1 require 1 comparison. Elements in row 2 require 2 comparisons. Elements in row 3 require 3 comparisons. In general, elements in row k require k comparisons.

Example: Binary Search Trees Further analysis Row 1 contains 1 element. Row 2 contains 2 elements. Row 3 contains 4 elements. In general, row k contains 2 k - 1 elements. Fact The average number of comparisons is the total number of comparisons required for all elements divided by the number of elements.

Example: Binary Search Trees The total number of elements is … + 2 n – 1. The total number of comparisons is 1     8 + … + n  2 n – 1. Therefore, the average is

Example: Binary Search Trees Prove by mathematical induction that … + 2 n – 1 = 2 n – 1. Prove by mathematical induction that 1     8 + … + n  2 n – 1 = (n – 1)2 n + 1. Then, the average is This is approximately equal to n – 1 (for large n).

Binary Search Trees In reality, it often requires two comparisons at each node. Is the value less than the node? If not, is the value greater than the node? If not, then the value equals the node. In other words, we must make a three-way decision at each node.

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees So, exactly how many comparisons does it take to locate an element?

Binary Search Trees It takes an average of 1.5 comparisons to move down one level. Then it takes 2 comparisons to match a value at that level. Level 1: 2 comparisons. Level 2: = 3.5 comparisons. Level 3: 2(1.5) + 2 = 5 comparisons. Level n: (n – 1)(1.5) + 2 = 1.5n

Binary Search Trees To find the average, we must compute 1   (3.5) + 4  5 + … + 2 n – 1  (1.5n + 0.5). We could work this our from scratch… Or use what we have already worked out:

Binary Search Trees Therefore, the average is For large n, this is approximately 1.5n – 1.

Binary Search Trees What if we changed the order in which we did the comparisons at each node? Is the value equal to the node? If not, is the value less than the node? If not, then the value is greater than the node. Will that be more or less efficient than the previous order?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees Exactly how many comparisons does it take to locate an element?

Binary Search Trees To find the average, we must compute 1    5 + … + 2 n – 1  (2n – 1). Again, we can use what we have already worked out:

Binary Search Trees Therefore, the average is For large n, this is approximately 2n – 3. This is larger (worse) than 1.5n – 1. Therefore, it is better not to check for equality first when searching a binary tree.

Example: Recursive Sequences Define a sequence a 1 = 2, a n = 2a n – 1 – 1 for n  2. Find a non-recursive formula for a n and prove that it is correct. Analysis {a n } = {2, 3, 5, 9, 17, 33, …}. {a n – 1} = {1, 2, 4, 8, 16, 32, …}. Conjecture that a n = 2 n –

Example: Recursive Sequences Proof: Basic Step P(1) is true since a 1 = 2 = Inductive Step Suppose that a k = 2 k – for some k  1.

Example: Recursive Sequences Then a k + 1 = 2a k – 1 (by def.) = 2(2 k – 1 + 1) – 1 (by ind. hyp.) = 2 k + 2 – 1 = 2 k + 1. Therefore, P(k + 1) is true. Therefore, a n = 2 n + 1 for all n  1.

Example: Contest Problem Let n be a positive integer. Suppose we have n red dots and n blue dots in the plane such that no three dots are collinear. Prove that it is possible to connect the red dots to the blue dots in distinct pairs such that none of the line segments intersect.

Example: Contest Problem

Proof: Basic Step P(1) is obviously true since there is only one pair of dots and only one segment.

Example: Contest Problem Proof: Basic Step P(1) is obviously true since there is only one pair of dots and only one segment.

Example: Contest Problem Inductive Step Suppose P(1), …, P(k) are true for some k  1. Now suppose we have a collection of k + 1 red dots and k + 1 blue dots. Consider the convex hull of this set.

Example: Contest Problem There are two possibilities. Case 1: The dots on the convex hull are not all the same color. Case 2: The dots on the convex hull are all the same color.

Example: Contest Problem There are two possibilities. Case 1: The dots on the convex hull are not all the same color. Case 2: The dots on the convex hull are all the same color.

Example: Contest Problem Case 1: Suppose they are not all the same color. Choose two adjacent dots of different colors on the convex hull and connect them with a segment.

Example: Contest Problem

By induction, the remaining collection of k red dots and k blue dots may be connected so that no two segments intersect. Nor will any of those segments intersect the first segment because it is on the convex hull and no three dots are collinear. Therefore, the entire set of dots may be connected with non-intersecting segments.

Example: Contest Problem

Case 2: Suppose they are all the same color, say red. Choose a line that is not parallel to any segment connecting any two dots. Move the line across the set of dots, from right to left. Keep count of the number of red dots and the number of blue dots to the right of the line.

Example: Contest Problem 0 red dots, so far (r = 0). 0 blue dot, so far (b = 0).

Example: Contest Problem 1 red dots, so far (r = 1). 0 blue dot, so far (b = 0).

Example: Contest Problem 1 red dots, so far (r = 1). 1 blue dot, so far (b = 1).

Example: Contest Problem 2 red dots, so far (r = 2). 1 blue dot, so far (b = 1).

Example: Contest Problem 3 red dots, so far (r = 3). 1 blue dot, so far (b = 1).

Example: Contest Problem Initially, r – b = 0. At the end, r – b = 0. Just after passing the first dot, r – b = 1. Just before passing the last dot, r – b = –1. The line meets only one dot at a time. Therefore, somewhere in between, r – b must be 0.

Example: Contest Problem 3 red dots (r = 3). 1 blue dot (b = 1). r – b = 2.

Example: Contest Problem 3 red dots (r = 3). 2 blue dot (b = 2). r – b = 1.

Example: Contest Problem 3 red dots (r = 3). 3 blue dot (b = 3). r – b = 0.

Example: Contest Problem Apply the induction hypothesis. The dots on the right may be connected with non-intersecting segments. The dots on the left may be connected with non-intersecting segments. Therefore, the entire set of dots may be connected with non-intersecting segments.

Example: Contest Problem Therefore, P(n) is true for all n  1.

Example: Contest Problem Therefore, P(n) is true for all n  1.

Example: Contest Problem Therefore, P(n) is true for all n  1.