April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.

Slides:



Advertisements
Similar presentations
CSE 211- Discrete Structures
Advertisements

Fall 2002CMSC Discrete Structures1 Now it’s Time for… RecurrenceRelations.
Recursive Definitions and Structural Induction
CS 2210 (22C:19) Discrete Structures Advanced Counting
Part 5. Computational Complexity (3)
Relations.
5/16/20151 You Never Escape Your… Relations. 5/16/20152Relations If we want to describe a relationship between elements of two sets A and B, we can use.
Applied Discrete Mathematics Week 11: Graphs
CSE115/ENGR160 Discrete Mathematics 04/19/12 Ming-Hsuan Yang UC Merced 1.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Analysis of Recursive Algorithms
Data Structures and Algorithms1 Basics -- 2 From: Data Structures and Their Algorithms, by Harry R. Lewis and Larry Denenberg (Harvard University: Harper.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Analysis of Recursive Algorithms October 29, 2014
Applied Discrete Mathematics Week 9: Relations
Time Complexity Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
(CSC 102) Lecture 15 Discrete Structures. Previous Lectures Summary  Procedural Versions  Properties of Sets  Empty Set Properties  Difference Properties.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
CS Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 Ofc hr: Thur, 9:30-11:30a Fall 2002KSU - Discrete Structures1.
Analysis of Algorithms
Project 2 due … Project 2 due … Project 2 Project 2.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Unit – 1 : FOUNDATIONS Syllabus: Sets – relations – equivalence relations partial orders – functions – recursive functions sequences – induction principle.
14.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo –Divide & conquer –Master’s method.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
Module #17: Recurrence Relations Rosen 5 th ed., §
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Discrete Structures1 You Never Escape Your… Relations.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
Lecture on Relations 1Developed by CSE Dept., CIST Bhopal.
7.3 Divide-and-Conquer Algorithms and Recurrence Relations If f(n) represents the number of operations required to solve the problem of size n, it follow.
7.2 Solving Linear Recurrence Relations Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Recurrence Relations. Outline Recurrence relationsSolving recurrence relationsRecurrence and Divide-and-conquer algorithmsGenerating functions
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
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.
Advanced Counting Techniques
Discrete Mathematical
Citra Noviyasari, S.Si, MT
CMSC Discrete Structures
Relations.
Modeling with Recurrence Relations
Applied Discrete Mathematics Week 11: Relations
Applied Discrete Mathematics Week 10: Relations
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from.
Applied Discrete Mathematics Week 9: Equivalence Relations
Module #17: Recurrence Relations
Relations and Their Properties
Applied Discrete Mathematics Week 5: Boolean Algebra
Module #17: Recurrence Relations
Applied Discrete Mathematics Week 9: Integer Properties
Divide and Conquer Algorithms Part I
CS 2210 Discrete Structures Advanced Counting
CMSC Discrete Structures
Solving Recurrence Relations
Applied Discrete Mathematics Week 7: Computation
9.5 Equivalence Relations
CMSC Discrete Structures
At the end of this session, learner will be able to:
Recurrence Relations Discrete Structures.
Presentation transcript:

April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci numbers. Solution: The Fibonacci numbers satisfy the recurrence relation f n = f n-1 + f n-2 with initial conditions f 0 = 0 and f 1 = 1. The characteristic equation is r 2 – r – 1 = 0. Its roots are

April 9, 2015Applied Discrete Mathematics Week 9: Relations 2 Solving Recurrence Relations Therefore, the Fibonacci numbers are given by for some constants  1 and  2. We can determine values for these constants so that the sequence meets the conditions f 0 = 0 and f 1 = 1:

April 9, 2015Applied Discrete Mathematics Week 9: Relations 3 Solving Recurrence Relations The unique solution to this system of two equations and two variables is So finally we obtained an explicit formula for the Fibonacci numbers:

April 9, 2015Applied Discrete Mathematics Week 9: Relations 4 Solving Recurrence Relations But what happens if the characteristic equation has only one root? How can we then match our equation with the initial conditions a 0 and a 1 ? Theorem: Let c 1 and c 2 be real numbers with c 2  0. Suppose that r 2 – c 1 r – c 2 = 0 has only one root r 0. A sequence {a n } is a solution of the recurrence relation a n = c 1 a n-1 + c 2 a n-2 if and only if a n =  1 r 0 n +  2 nr 0 n, for n = 0, 1, 2, …, where  1 and  2 are constants.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 5 Solving Recurrence Relations Example: What is the solution of the recurrence relation a n = 6a n-1 – 9a n-2 with a 0 = 1 and a 1 = 6? Solution: The only root of r 2 – 6r + 9 = 0 is r 0 = 3. Hence, the solution to the recurrence relation is a n =  1 3 n +  2 n3 n for some constants  1 and  2. To match the initial conditions, we need a 0 = 1 =  1 a 1 = 6 =  1  3 +  2  3 Solving these equations yields  1 = 1 and  2 = 1. Consequently, the overall solution is given by a n = 3 n + n3 n.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 6 Divide-and-Conquer Relations Some algorithms take a problem and successively divide it into one or more smaller problems until there is a trivial solution to them. For example, the binary search algorithm recursively divides the input into two halves and eliminates the irrelevant half until only one relevant element remained. This technique is called “divide and conquer”. We can use recurrence relations to analyze the complexity of such algorithms.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 7 Divide-and-Conquer Relations Suppose that an algorithm divides a problem (input) of size n into a subproblems, where each subproblem is of size n/b. Assume that g(n) operations are performed for such a division of a problem. Then, if f(n) represents the number of operations required to solve the problem, it follows that f satisfies the recurrence relation f(n) = af(n/b) + g(n). This is called a divide-and-conquer recurrence relation.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 8 Divide-and-Conquer Relations Example: The binary search algorithm reduces the search for an element in a search sequence of size n to the binary search for this element in a search sequence of size n/2 (if n is even). Two comparisons are needed to perform this reduction. Hence, if f(n) is the number of comparisons required to search for an element in a search sequence of size n, then f(n) = f(n/2) + 2 if n is even.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 9 Divide-and-Conquer Relations Usually, we do not try to solve such divide-and conquer relations, but we use them to derive a big-O estimate for the complexity of an algorithm. Theorem: Let f be an increasing function that satisfies the recurrence relation f(n) = af(n/b) + cn d whenever n = b k, where k is a positive integer, a, c, and d are real numbers with a  1, and b is an integer greater than 1. Then f(n) is O(n d ), if a < b d, O(n d log n) if a = b d, O(n log b a ) if a > b d

April 9, 2015Applied Discrete Mathematics Week 9: Relations 10 Divide-and-Conquer Relations Example: For binary search, we have f(n) = f(n/2) + 2, so a = 1, b = 2, and d = 0 (d = 0 because here, g(n) does not depend on n). Consequently, a = b d, and therefore, f(n) is O(n d log n) = O(log n). The binary search algorithm has logarithmic time complexity.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 11 How About Some… Relations

April 9, 2015Applied Discrete Mathematics Week 9: Relations 12Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element taken from A and their second element taken from B. Since this is a relation between two sets, it is called a binary relation. Definition: Let A and B be sets. A binary relation from A to B is a subset of A  B. In other words, for a binary relation R we have R  A  B. We use the notation aRb to denote that (a, b)  R and ab to denote that (a, b)  R. In other words, for a binary relation R we have R  A  B. We use the notation aRb to denote that (a, b)  R and aRb to denote that (a, b)  R.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 13Relations When (a, b) belongs to R, a is said to be related to b by R. Example: Let P be a set of people, C be a set of cars, and D be the relation describing which person drives which car(s). P = {Carl, Suzanne, Peter, Carla}, C = {Mercedes, BMW, tricycle} D = {(Carl, Mercedes), (Suzanne, Mercedes), (Suzanne, BMW), (Peter, tricycle)} This means that Carl drives a Mercedes, Suzanne drives a Mercedes and a BMW, Peter drives a tricycle, and Carla does not drive any of these vehicles.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 14 Functions as Relations You might remember that a function f from a set A to a set B assigns a unique element of B to each element of A. The graph of f is the set of ordered pairs (a, b) such that b = f(a). Since the graph of f is a subset of A  B, it is a relation from A to B. Moreover, for each element a of A, there is exactly one ordered pair in the graph that has a as its first element.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 15 Functions as Relations Conversely, if R is a relation from A to B such that every element in A is the first element of exactly one ordered pair of R, then a function can be defined with R as its graph. This is done by assigning to an element a  A the unique element b  B such that (a, b)  R.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 16 Relations on a Set Definition: A relation on the set A is a relation from A to A. In other words, a relation on the set A is a subset of A  A. Example: Let A = {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a < b} ?

April 9, 2015Applied Discrete Mathematics Week 9: Relations 17 Relations on a Set Solution: R = { (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)} R XXX XX X

April 9, 2015Applied Discrete Mathematics Week 9: Relations 18 Relations on a Set How many different relations can we define on a set A with n elements? A relation on a set A is a subset of A  A. How many elements are in A  A ? There are n 2 elements in A  A, so how many subsets (= relations on A) does A  A have? The number of subsets that we can form out of a set with m elements is 2 m. Therefore, 2 n 2 subsets can be formed out of A  A. Answer: We can define 2 n 2 different relations on A.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 19 Properties of Relations We will now look at some useful ways to classify relations. Definition: A relation R on a set A is called reflexive if (a, a)  R for every element a  A. Are the following relations on {1, 2, 3, 4} reflexive? R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No. R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes. R = {(1, 1), (2, 2), (3, 3)} No. Definition: A relation on a set A is called irreflexive if (a, a)  R for every element a  A.

April 9, 2015Applied Discrete Mathematics Week 9: Relations 20 Properties of Relations Definitions: A relation R on a set A is called symmetric if (b, a)  R whenever (a, b)  R for all a, b  A. A relation R on a set A is called antisymmetric if a = b whenever (a, b)  R and (b, a)  R. A relation R on a set A is called asymmetric if (a, b)  R implies that (b, a)  R for all a, b  A.