ICS141: Discrete Mathematics for Computer Science I

Similar documents
With Question/Answer Animations

Induction and recursion. Topics. Induction and Recursion Vojislav Kecman CMSC 302

Induction and Recursion

Induction and recursion. Chapter 5

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

ICS141: Discrete Mathematics for Computer Science I

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

INDUCTION AND RECURSION. Lecture 7 - Ch. 4

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Discrete Mathematics. Spring 2017

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I

Recursive Definitions

ICS141: Discrete Mathematics for Computer Science I

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

8. Sequences, Series, and Probability 8.1. SEQUENCES AND SERIES

Discrete Mathematics. Spring 2017

Big , and Definition Definition

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Strong Mathematical Induction

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Discrete Structures CRN Test 3 Version 1 CMSC 2123 Autumn 2013

IS 709/809: Computational Methods for IS Research. Math Review: Algorithm Analysis

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

What is this course about?

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

CSCE 222 Discrete Structures for Computing. Proof by Induction. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

Carmen s Core Concepts (Math 135)

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

ICS141: Discrete Mathematics for Computer Science I

Climbing an Infinite Ladder

Mathematical Induction

V. Adamchik 1. Recurrences. Victor Adamchik Fall of 2005

Binomial Coefficient Identities/Complements

Math/EECS 1028M: Discrete Mathematics for Engineers Winter Suprakash Datta

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Notes on induction proofs and recursive definitions

Recurrence Relations and Recursion: MATH 180

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Lecture 7: Dynamic Programming I: Optimal BSTs

Proof by Induction. Andreas Klappenecker

Proof Techniques (Review of Math 271)

CS1800: Mathematical Induction. Professor Kevin Gold

CSC 344 Algorithms and Complexity. Proof by Mathematical Induction

EECS 1028 M: Discrete Mathematics for Engineers

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

CSC236H Lecture 2. Ilir Dema. September 19, 2018

Automata Theory and Formal Grammars: Lecture 1

Models of Computation. by Costas Busch, LSU

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17

Remainders. We learned how to multiply and divide in elementary

Theory of Computation

Section Summary. Relations and Functions Properties of Relations. Combining Relations

Exam in Discrete Mathematics

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

ICS141: Discrete Mathematics for Computer Science I

Discrete Mathematics: Lectures 6 and 7 Sets, Relations, Functions and Counting Instructor: Arijit Bishnu Date: August 4 and 6, 2009

Propositional Logic, Predicates, and Equivalence

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Administrivia. COMP9020 Lecture 7 Session 2, 2017 Induction and Recursion. Lecture 6 recap. Lecture 6 recap

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

IS 709/809: Computational Methods in IS Research Fall Exam Review

Section 11.1 Sequences

Mathematical Induction. Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition)

Propositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications

MAT 243 Test 2 SOLUTIONS, FORM A

CS 250/251 Discrete Structures I and II Section 005 Fall/Winter Professor York

Lecture 6 September 21, 2016

Mathematical Fundamentals

1 Sequences and Summation

CS1800 Discrete Structures Final Version A

Strong Induction (Second Principle) Example: There are two piles of cards, players take turn: each turn: one player removes any number of cards from

CS375: Logic and Theory of Computing

Name CMSC203 Fall2008 Exam 2 Solution Key Show All Work!!! Page (16 points) Circle T if the corresponding statement is True or F if it is False.

Relations. We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples.

Midterm 1 for CS 170

What we have done so far

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

PRINCIPLE OF MATHEMATICAL INDUCTION

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

CS383, Algorithms Spring 2009 HW1 Solutions

Exercises for Discrete Maths

Chapter Summary. Sets (2.1) Set Operations (2.2) Functions (2.3) Sequences and Summations (2.4) Cardinality of Sets (2.5) Matrices (2.

Recursion: Introduction and Correctness

Mathematical Preliminaries. Sipser pages 1-28

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Discrete Mathematics & Mathematical Reasoning Course Overview

CSE 311: Foundations of Computing. Lecture 16: Recursion & Strong Induction Applications: Fibonacci & Euclid

Transcription:

ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by McGraw-Hill 13-1

Quiz 1. State the 1 st Principle of Mathematical Induction 2. What is the difference between the 1 st, 2 nd and strong principles of Mathematical Induction. (Describe in plain English) 3. What is the big-o complexity of Euclid's Algorithm? 13-2

Lecture 21 Chapter 4. Induction and Recursion 4.3 Recursive Definitions and Structural Induction 13-3

Recursive Definitions n In induction, we prove all members of an infinite set satisfy some predicate P by: n proving the truth of the predicate for larger members in terms of that of smaller members. n In recursive definitions, we similarly define a function, a predicate, a set, or a more complex structure over an infinite domain (universe of discourse) by: n defining the function, predicate value, set membership, or structure of larger elements in terms of those of smaller ones. 13-4

Recursion n Recursion is the general term for the practice of defining an object in terms of itself n or of part of itself. n This may seem circular, but it isn t necessarily. n An inductive proof establishes the truth of P(k+1) recursively in terms of P(k). n There are also recursive algorithms, definitions, functions, sequences, sets, and other structures. 13-5

Recursively Defined Functions n Simplest case: One way to define a function f:n S (for any set S) or series a n = f(n) is to: n Define f(0) n For n > 0, define f(n) in terms of f(0),,f(n 1) n Example: Define the series a n = 2 n where n is a nonnegative integer recursively: n a n looks like 2 0, 2 1, 2 2, 2 3, n Let a 0 = 1 n For n > 0, let a n = 2 a n 1 13-6

Another Example n Suppose we define f(n) for all n N recursively by: n Let f(0) = 3 n For all n > 0, let f(n) = 2 f(n 1) + 3 n What are the values of the following? n f(1) = 2 f(0) + 3 = 2 3 + 3 = 9 n f(2) = 2 f(1) + 3 = 2 9 + 3 = 21 n f(3) = 2 f(2) + 3 = 2 21 + 3 = 45 n f(4) = 2 f(3) + 3 = 2 45 + 3 = 93 13-7

Recursive Definition of Factorial n Give an inductive (recursive) definition of the factorial function, F(n) = n! = 1 i n i = 1 2 n n Basis step: F(1) = 1 n Recursive step: F(n) = n F(n 1) for n > 1 n F(2) = 2 F(1) = 2 1 = 2 n F(3) = 3 F(2) = 3 {2 F(1)} = 3 2 1 = 6 n F(4) = 4 F(3) = 4 {3 F(2)} = 4 {3 2 F(1)} = 4 3 2 1 = 24 13-8

The Fibonacci Numbers n The Fibonacci numbers f n 0 is a famous series defined by: f 0 = 0, f 1 = 1, f n 2 = f n 1 + f n 2 0 1 1 2 3 5 8 13 13-9

Inductive Proof about Fibonacci Numbers n Theorem: f n < 2 n. Implicitly for all n N n Proof: By induction n Basis step: f 0 = 0 < 2 0 = 1 f 1 = 1 < 2 1 = 2 Note: use of base cases of recursive definition n Inductive step: Use 2 nd principle of induction (strong induction). Assume 0 i k, f i < 2 i. Then f k+1 = f k + f k 1 is < 2 k + 2 k 1 < 2 k + 2 k = 2 k+1. 13-10

A Lower Bound on Fibonacci Numbers n Theorem: For all integers n 3, f n > α n 2, where α = (1 + 5 1/2 )/2 1.61803. n Proof. (Using strong induction.) n Let P(n) = (f n > α n 2 ). n Basis step: For n = 3, note that α n 2 = α < 2 = f 3. For n = 4, α n 2 = α 2 = (1 + 2 5 1/2 + 5)/4 = (3 + 5 1/2 )/2 2.61803 (= α + 1) < 3 = f 4. 13-11

A Lower Bound on Fibonacci Numbers: Proof Continues n Inductive step: For k 4, assume P(j) for 3 j k, prove P(k+1). n f k+1 = f k + f k 1 > α k 2 + α k 3 (by inductive hypothesis, f k 1 > α k 3 and f k > α k 2 ). n Note that α 2 = α + 1. since (3 + 5 1/2 )/2 = (1 + 5 1/2 )/2 + 1 n Thus, α k 1 = α 2 α k 3 = (α + 1)α k 3 = αα k 3 + α k 3 = α k 2 + α k 3. n So, f k+1 = f k + f k 1 > α k 2 + α k 3 = α k 1. n Thus P(k+1). 13-12

Recursively Defined Sets n An infinite set S may be defined recursively, by giving: n A small finite set of base elements of S. n A rule for constructing new elements of S from previously-established elements. n Implicitly, S has no other elements but these. base element (basis step) construction rule (recursive step) n Example: Let 3 S, and let x+y S if x,y S. What is S? 13-13

Example cont. n Let 3 S, and let x+y S if x,y S. What is S? n 3 S (basis step) n 6 (= 3 + 3) is in S (first application of recursive step) n 9 (= 3 + 6) and 12 (= 6 + 6) are in S (second application of the recursive step) n 15 (= 3 + 12 or 6 + 9), 18 (= 6 + 12 or 9 + 9), 21 (= 9 + 12), 24 (= 12 + 12) are in S (third application of the recursive step) n so on n Therefore, S = {3, 6, 9, 12, 15, 18, 21, 24, } = set of all positive multiples of 3 13-14

The Set of All Strings n n Given an alphabet Σ, the set Σ * of all strings over Σ can be recursively defined by: n Basis step: λ Σ * (λ : empty string) n Recursive step: (w Σ * x Σ) wx Σ * Example: If Σ = {0, 1} then n λ Σ* (basis step) n 0 and 1 are in Σ* (first application of recursive step) n 00, 01, 10, and 11 are in Σ* (second application of the recursive step) n so on n Therefore, Σ* consists of all finite strings of 0 s and 1 s together with the empty string 13-15

String: Example n Show that if Σ = {a, b} then aab is in Σ*. Proof: We construct it with a finite number of applications of the basis and recursive steps in the definition of Σ*: 1. λ Σ* by the basis step. 2. By step 1, the recursive step in the definition of Σ* and the fact that a Σ, we can conclude that λa = a Σ*. 13-16

Proof cont. 3. Since a Σ* from step 2, and a Σ, applying the recursive step again we conclude that aa Σ*. 4. Since aa Σ* from step 3 and b Σ, applying the recursive step again we conclude that aab Σ*. n Since we have shown aab Σ* with a finite number of applications of the basis and recursive steps in the definition we have finished the proof. 13-17

Rooted Trees n Trees will be covered in more depth in chapter 10. n n n Briefly, a tree is a graph in which there is exactly one undirected path between each pair of nodes. An undirected graph can be represented as a set of unordered pairs (called arcs) of objects called nodes. Definition of the set of rooted trees: n Basis step: Any single node r is a rooted tree. n Recursive step: If T 1,, T n are disjoint rooted trees with respective roots r 1,, r n, and r is a node not in any of the T i s, then another rooted tree is {(r, r 1 ),, (r, r n )} T 1 T n. 13-18

Illustrating Rooted Tree Definition n How rooted trees can be combined to form a new rooted tree r T 1 r 1 T 2 r 2 T n r n 13-19

Building Up Rooted Trees 13-20

Extended Binary Trees n A special case of rooted trees. n Recursive definition of extended binary trees: n Basis step: The empty set is an extended binary tree. n Recursive step: If T 1, T 2 are disjoint extended binary trees, then e 1 e 2 T 1 T 2 is an extended binary tree, where e 1 = if T 1 =, and e 1 = {(r, r 1 )} if T 1 and has root r 1, and similarly for e 2. (T 1 is the left subtree and T 2 is the right subtree.) 13-21

Building Up Extended Binary Trees 13-22

Lamé s Theorem n Theorem: a,b N, a b>0, and let n be the number of steps Euclid s algorithm needs to compute gcd(a,b). Then n 5k, where k = log 10 b +1 is the number of decimal digits in b. n Thus, Euclid s algorithm is linear-time in the number of digits in b. (or, Euclid s algorithm is O(log a)) n Proof: n Uses the Fibonacci sequence! (See next!) 13-23

Proof of Lamé s Theorem n Consider the sequence of division-algorithm equations used in Euclid s alg.: r 0 = r 1 q 1 + r 2 with 0 r 2 < r 1 r 1 = r 2 q 2 + r 3 with 0 r 3 < r 2 Where a = r 0, b = r 1, and gcd(a,b)=r n. r n 2 = r n 1 q n 1 + r n with 0 r n < r n 1 r n 1 = r n q n + r n+1 with r n+1 = 0 (terminate) n The number of divisions (iterations) is n. Continued on next slide 13-24

Lamé Proof cont. n Since r 0 r 1 > r 2 > > r n, each quotient q i r i 1 /r i 1. n Since r n 1 = r n q n and r n 1 > r n, q n 2. n So we have the following relations between r and f: r n 1 = f 2 r n 1 2r n 2f 2 = f 3 r n 2 r n 1 + r n f 2 + f 3 = f 4 r 2 r 3 + r 4 f n 1 + f n 2 = f n b = r 1 r 2 + r 3 f n + f n 1 = f n+1. n Thus, if n > 2 divisions are used, then b f n+1 > α n 1. n Thus, log 10 b > log 10 (α n 1 ) = (n 1)log 10 α (n 1)0.208 > (n 1)/5. n If b has k decimal digits, then log 10 b < k, so n 1 < 5k, so n 5k. 13-25