Discrete Structure I November 2010 Lecture Notes

Embed Size (px)

Citation preview

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    1/32

    1

    Discrete Structures IDraft Lecture Notes By

    Omari C.ODepartment of Statistics and Actuarial Science

    Kimathi University College of TechnologySeptember, 2010

    Course Outline

    Propositional and predicate calculus, Boolean algebra, introduction to complexity of algo-rithms, mathematical reasoning, counting, recurrences, relations, and introduction to graphs.

    Further Reading Books

    1. Discrete Mathematics, 2nd edition, Seymour Lipschutz and Marc Lipson (schaums se-ries).

    2. Data Structures, Seymour Lipschutz, Schaums outlines.

    3. Kennrth H. Rosen, Discrete Mathematics and its Applications, 6th edition, 2007, Mc-Graw Hill.

    4. Goodaire and Parmenter, Discrete Mathematics with Graph Theory, 3rd edition 2006,Prentice Hall.

    5. Ralph P. Grimaldi, Discrete and Combinatorial Mathematics, 5th edition, 2004, AddisonWesley.

    6. Kolman, Busby, and Ross, Discrete Mathematical Structures, 5th edition, 2004, PrenticeHall.

    7. D.S. Malik and M.K. Sen, Discrete Mathematics

    Course Evaluation

    1. Three CATS: 20%

    2. Two Assignments: 10%

    3. Final Semester Examinations: 70%

    Lecture Hours

    Wednesday:

    Consultation Hours

    Tuesday: 9.00am - 1.00pm and Wednesday: 2.00pm - 5.00pm

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    2/32

    Chapter 1

    Mathematical Logic andPropositional Calculus

    Introduction

    Logic is the discipline that considers the methods of reasoning. It provides the rules and tech-niques for determining whether an argument is valid or not.

    In mathematics and computer science, mathematical logic or logic is used to prove results.Specifically, in mathematics we use logic or logical reasoning to prove theorems, and in com-puter science we use logical or logical reasoning to prove the correctness of programs and alsoto prove theorems.

    A theorem is a statement that can be shown to be true (under certain conditions). For exam-ple, in mathematics the following statement is a theorem,

    If x is an even integer, then x + 1 is an odd integer.

    It can be proved that the above statement under the condition that x is an integer is true.A proof of a theorem is an argument consisting of a sequence of statements aimed at demon-strating the truth of the assertion.

    Many proofs in mathematics and many algorithms in computer science use logical expres-sions such as,

    If p then q, or If p1 and p2, then q1 or q2.

    It is therefore necessary to know the cases in which these expressions are either true orfalse: what we refer to as truth values of such expressions.

    We also investigate the truth value of quantified statements, which are statements which usethe logical quantifier for every and there exists.

    Proposition and compound propositions

    A proposition (or statement) is a declarative sentence that is either true or false, but not both.Consider, for example the following sentences:

    (i). 4 is an integer

    (ii). 5 is an integer

    2

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    3/32

    3

    (iii). x = 2 is a solution of x2 = 4

    (iv). 9 < 6.

    (v). Every even integer greater than 4 is a sum of two odd primes.

    (vi). Will you pass this unit?

    (vii). Enjoy the semester ahead!

    Each of these sentences is a declarative sentence, except (v), (vi) and (vii). Sentence (i) istrue, sentence (ii) is not true, sentence (iii) is true,and sentence (iv) is true. Hence, these areexamples of statements.

    For sentence (v), so far, no one has been able to prove that this is true. At the same time, noone has proved that it is false. nevertheless, the sentence above is a statement because it iseither, true or false, but not both. This is known as the Goldbachs conjecture.

    Sentences, (vi) and (vii) are not declarative sentences, so these are not statements.

    By definition, a statement is a declarative sentence that can be classified as true or false,but not both. Thus, on e of the values truth or falsity that is assigned to a statement iscalled its truth value. We abbreviate truth to T or 1 and falsity to F or 0.

    Consider the following inferences:

    a < b or a > cIt is not the case that a < b.Therefore: a > c.

    The first two sentences of the inference are called premises and the last sentence is calledthe conclusion. Any simple sentence e.g. a < b is called an atomic sentence. One or moreatomic sentences may be joined to make up compound sentences using connectives.

    Compound propositions

    Many propositions are composite, that is, composed of sub-propositions and various connec-tives to be discussed later. Such composite propositions are called compound propositions.

    A proposition is said to be primitive if it cannot be broken down into simpler propositions,

    that is, if it is not composite.

    Example 1.0.1. Consider the following compound propositions.

    (a). Roses are Red and Violets are Blue is a compound proposition with sub-propositionsRoses are Red and Violets are Blue.

    (b). John is intelligent or studies every night is a compound proposition with sub-propositionsJohn is intelligent and John studies every night.

    (c). The above propositions (i) through to (iv) are all primitive propositions; they cannot bebroken down into simpler propositions.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    4/32

    4

    Note: The fundamental property of a compound proposition is that its truth value is com-pletely determined by the truth value of its sub-propositions together with the way in whichthey are connected to form the compound proposition.

    Basic Logical Operations

    The three basic logical operators are:

    1. Negation

    2. Conjunction

    3. Disjunction

    They correspond respectively, to the English words, NOT, AND, and OR.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    5/32

    Chapter 2

    Counting Principles

    2.1 Basic Counting Principles

    There are two main basic counting techniques

    1. Addition principle

    2. Multiplication principle

    2.1.1 Addition Principle

    Suppose that we want to find the number of integers between 4 and 100 that end with 3 or 5.Let T denote this task. We divide T into the following tasks.

    T1: Find all integers between 4 and 100 that end with 3.

    T2: Find all integers between 4 and 100 that end with 5.Now 13, 23, 33, 43, 53, 63, 73, 83, and 93 are 9 digits between 4 and 100 that end with 3; and5, 15, 25, 35, 45, 55, 65, 75, 85, and 95 are 10 integers between 4 and 100 that end with 5.Hence, tasks T1 and T2 can be done in 9 and 10 ways, respectively. Both tasks are independentof each other; i.e., they can be completed in any order because their outcomes do not dependon each. Therefore, the number of ways to do one of these tasks is 9 + 10 = 19. Hence, thenumber of integers between 4 and 100 that end with 3 or 5 is 19. That is, task T can becompleted in 19 ways.

    If we look closely at the preceding counting method, we see that it is connected with theunion of two disjoint sets. For example, task T is the union of tasks T1 and T2.

    Addition Principle: Suppose that tasks T1, T2, , Tk can be done in n1, n2, , nk ways,respectively. If all these tasks are independent of each other, then the number of ways to doone of these tasks is

    n1 + n2 + + nkExample 2.1.1. There are three boxes containing books. The first box contains 15 math-ematics books by different authors, the second box contains 12 chemistry books by differentauthors, and the third box contains 10 computer science books by different authors. A studentwants to take a book from one of the three boxes. In how many ways can the student do this?

    Solution. If the student wants to take a mathematics book, then he/she can choose onemathematics book from 15 different mathematics books and he/she can do this in exactly

    5

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    6/32

    2.1 Basic Counting Principles 6

    15 ways. Similarly, the student can choose one chemistry book in exactly 12 ways and onecomputer science book in exactly 10 ways. Suppose tasks T1, T2, and T3 are as follows:

    T1: Choose a mathematics book

    T2: Choose a chemistry book

    T3: Choose a computer science book

    Then tasks T1, T2, and T3 can be done in 15, 12, and 10 ways, respectively. All of these tasksare independent of each other. Hence, the number of ways to do one of these tasks is

    15 + 12 + 10 = 37 ways

    2.1.2 Multiplication Principle

    Let us consider the following problem. Suppose we want to find the number of words of length3 that can be written using the letters A,B,C,D, and E such that no repetition of letters in

    a word is allowed. For example, BAD, ACB, AEB , BAE, BC E, and EDA are some of thewords of length 3 that do not contain repetition of letters.

    Let T be the task of constructing such a word and let X denote such a word. Then T can becompleted in three successive steps, T1, T2 and T3, in which;

    T1: Choose the first letter.

    T2: Choose the second letter.

    T3: Choose the third letter.

    The first letter of X can be any one of the letters A,B,C,D, or E. Therefore, the first letterof X can be chosen in 5 different ways. Thus, step T1 can be completed in 5 different ways.

    Once the first letter of X is chosen, the number of remaining letters in the given set is 4.Therefore the second letter ofX can be any one of the remaining 4 letters, so the second letterof X can be chosen in 4 ways. Thus, step T2 can be completed in 4 different ways.

    Suppose we choose A as the first letter of X.

    A

    Because repetitions of a letter are not allowed, in the second place we can put any one of theletters B,C,D, or E.

    AB, AC, AD, AE

    If follows that for each choice of completing step T1, step T2 can be completed in 4 ways.Hence, we find that steps T1 and T2 can be completed in 5 4 different ways.

    After choosing the first and the second letters of X, the number of remaining letters in thegiven set is 3. Therefore, the third letter of X can be any one of these 3 letters. Thus, thethird letter can be chosen in 3 ways: i.e., step T3 can be completed in 3 ways.

    Suppose we have chosen A in step T1 and B in step T2.

    A, B

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    7/32

    2.1 Basic Counting Principles 7

    Then we can complete step T3 in three different ways.

    ABC, ABD, ABE

    Because steps T1 and T2 can be completed in 5 4 ways, for each of these choices of 5 4 different

    ways, we can complete step T3 in 3 different ways. Consequently, steps T1, T2, and T3 can becompleted in 5 4 3 different ways. Hence, there are 60 different words of length 3 such thatno word contains a repetition of letters.

    Let us now consider a variation of the preceding problem. Suppose we want to find thenumber of words of length 3 that can be written by using the letters A,B,C,D and E suchthat repetition of letters in a word is allowed. BAB,ACB,AEE,BAA,BCE, and DDA areexamples of such words of length 3.

    As before, let T be the task of constructing such a word of length 3 and let t be such aword. The task T can be completed in three successive steps, T1, T2, and T3.

    T1: Choose the first letter.

    T2: Choose the second letter.

    T3: Choose the third letter.

    The first letter oft can be any one of the letters A,B,C,D, or E. Therefore, the first letter oftcan be chosen in 5 different ways. This implies that step T1 can be completed in 5 different ways.

    Because repetition of a letter is allowed, the second letter of t can be any one of the let-ters A,B,C,D, or E. Therefore, the second letter of t can be chosen in 5 different ways. Thatis, step T2 can be completed in 5 different ways.

    Suppose we choose A as the first letter.A

    Because repetition is allowed, in the second place we can write any one of the letter A,B,C,D,or E.

    AA, AB, AC, AD, AE

    It follows that steps T1 and T2 can be completed in 5 5 different ways.

    Next, the third letter of t can be any one of A,B,C,D, or E. Therefore, the third lettercan be chosen in 5 ways. Suppose we chose A in the first step, T1, and B in the second step,

    T2.AB

    Then we can complete the third step, T3, in 5 different ways

    ABA, ABB, , ABC, ABD, ABE

    We find that for each of the 5 5 different ways of completing steps T1 and T2, we can completestep T3 in 5 different ways.

    Consequently, steps T1, T2, and T3 can be completed in 5 5 5 different ways. Hence, there are125 different words of length 3 such that a word may contain repetition of letters.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    8/32

    2.1 Basic Counting Principles 8

    Multiplication Principle: Suppose that a task T can be completed in k successive steps.Suppose step 1 can be completed in n1 different ways, step 2 can be completed in n2 differ-ent ways, and in general, no matter how the preceding steps are completed, step k can becompleted in nk different ways. Then the task T can be completed in

    n1n2 nkdifferent ways.

    Example 2.1.2.

    2.1.3 Simultaneously Using Addition and Multiplication

    The counting problems that we have considered so far involved either the addition principleor the multiplication principle. Sometimes, however, we need to use both of these countingprinciples to solve a particular problem.

    Example 2.1.3. Determine the number of license plates that can be formed with 3 uppercaseletters followed by 3 digits such that the first letter is either A or B.

    Let X1 be the set of all license plates with 3 uppercase letters followed by 3 digits such thatthe first letter is A. Let X2 be the set of all license plates with 3 uppercase letters followedby 3 digits such that the first letter is B. Then X1 X2 is the set of all license plats with 3uppercase letters followed by 3 digits that can be formed such that the first letter is either Aor B. Because the license plates in the set X1 begin with A and the license plates in the setX2 begin with B, it follows that X1 X2 = . By the addition principle,

    |X1 X2| = |X1| + |X2|.

    Next we determine the number of elements in X1 and the number of elements in X2. Let L bea license plate in X1. Then L is of the form:

    A

    l1 l2 l3 d1 d2 d3

    The first letter can be chosen in only one way, each of the second and third letters can bechosen in 26 ways, and each of the digits can be chosen in 10 ways. Thus, by the multiplicationprinciple, the license plate L can be formed in;

    1 26 26 10 10 10 = 676, 000

    ways. Hence, |X1| = 676, 000.A license plate in the set X2 must begin with the uppercase letter B. By arguments sim-ilar to those determining the number of elements in X1, the number of elements in X2 is676,000; that is, |X2| = 676, 000. It now follows that

    |X1 X2 = |X1| + |X2| = 676, 000 + 676, 000 = 1, 352, 000.

    Therefore, the number of license plates with 3 uppercase letters followed by 3 digits that canbe formed such that the first letter is either A or B is 1,352,000.

    Example 2.1.4. The following items are available for breakfast: 4 types of cereal, 2 types

    of juice, and 3 types of bread. Determine the number of ways a breakfast can be prepared ifexactly two items are selected from two different groups.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    9/32

    2.1 Basic Counting Principles 9

    Solution. Because exactly two items must be selected from two different groups, a breakfastcan be prepared in either of the following three ways:

    (i). a cereal and a juice, or

    (ii). a cereal and a bread, or

    (iii). a juice and a bread

    LetX be the set of breakfasts that consist of a cereal and a juice;Y be the set of breakfasts that consist of a cereal and a bread; andZ be the set of all breakfasts that consist of a juice and a bread.

    Then X Y Z is the set of all breakfasts that consist of exactly two items from two differentgroups. Notice that X Y = , X Z = , and Y Z = ; that is, the sets X, Y, and Z arepairwise disjoint.

    We can now apply the addition principle to conclude that|X Y Z| = |X| + |Y| + |Z|.

    Next we determine, |X|, and |Y|, and |Z|.

    A breakfast in set X consists of a cereal and a juice. Thus, we can first select a cereal and thena juice. Now a cereal can be selected in 4 ways and a juice can be selected in 2 ways. Thus,by the multiplication principle, a breakfast consisting of a cereal and a juice can be preparedin 4 2 ways. therefore, |X| = 8. In similar manner, we can show that |Y| = 4 3 = 12 and|Y| = 2 3 = 6. Consequently,

    |X

    Y

    Z

    |=

    |X

    |+

    |Y

    |+

    |Z

    |= 8 + 12 + 6 = 26.

    2.1.4 The Principle of Inclusion-Exclusion

    Consider two finite sets, X1 and X2. To count the number of elements in X1 X2, we firstcount the number of elements in X1 and then add the number of elements in X2. However, inthis process the elements that are common to X1 and X2 are counted twice-once to determine|X1| and the second time to determine |X2|. Therefore, to determine the number of elementsin X1 X2, we must subtract |X1 X2| from |X1| + |X2|, i.e.,

    |X1 X2| = |X1| + |X2| |X1 X2|Let A and B be any finite sets. Then

    n(A B) = n(A) + n(B) n(A B).Example 2.1.5. Let A be the set of positive integers that are 30 and multiples of 4. LetB be the set of positive integers that are 30 and multiples of 6. We want to determine thenumber of distinct elements in A B.Now A = {4, 8, 12, 16, 20, 24, 28} and B = {6, 12, 18, 24, 30}. Then A B = {12, 24}. Also,|A| = 7, |B| = 5, and |A B| = 2. Hence,

    |A B| = |A| + |B| |A B| = 7 + 5 2 = 10.A direct calculation, i.e., writing the elements of A B, also shows that |A B| = 10.

    Another way to find the number of elements in A is as follows: Because A is the set ofpositive integers that are 30 and multiples of 4, it follows that |A| = 304 = 7.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    10/32

    2.1 Basic Counting Principles 10

    Example 2.1.6. Let A denote the set of bit strings of length 6 that begin with 101 and Bdenote the set of bit strings of length 6 that terminate at 00. Determine the number of elementsin A B.Solution. An element of A is of the form 101a4a5a6, where each ai is 0 or 1. Therefore, bythe multiplication principle, the number of elements in A,

    |A

    |= 2

    2

    2 = 8.

    An element of B is of the form b1b2b3b400, where each bi is 0 or 1. It follows that the numberof elements in B is |B| = 2 2 2 2 = 16.

    Let us now count the number of elements in A B. An element of A B is a bit stringof length 6 that starts with 101 and ends with 00. Thus, an element of A B is of the form101c400, where c4 is 0 or 1. It follows that the number of elements in A B, |A B| = 2.

    |A B| = |A| + |B| |A B| = 8 + 16 2 = 22.Example 2.1.7. How many positive integers

    100 are multiples of 4, 5, or 6?

    Question 2.1.1. How many positive integers 1, 000 are multiples of(a). 2, 3,or 5?

    (b). 4, 6 or 20?

    (c). not multiples of 4, 6, or 20?

    (d). not multiples of 8, 12 , or 20?

    Question 2.1.2. How many positive integers 100 are multiples of 2 or multiples of 3?Question 2.1.3. How many positive integers

    200 are multiples of

    (a). 3 or 5?

    (b). 4 or 6?

    (c). not multiples of 2 or 17?

    (d). not multiples of 12 or 16?

    Next we extend formula to three finite sets, A,B, and C. We thus have;

    |A B C| = |A| + |B| + |C| |A B| |A C| |B C| + |A B C|

    where A, B, C are finite sets.Example 2.1.8. Determine all positive integers less than 2102 that are divisible by at leastone of the primes 2, 3, and 5.

    Solution. Let A, B and C be the set of all positive integers that are less than or equal to2102 and divisible by 2, 3, and 5 respectively i.e.,

    A =< 2 >, |A| = 2102/2 = 1051B =< 3 >, |B| = 2102/3 = 700C =< 5 >, |C| = 2102/5 = 420

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    11/32

    2.1 Basic Counting Principles 11

    Now A B is the set of all positive integers that are divisible by 2 and 3. Because 2 and 3 arerelatively prime, we can show that an integer is divisible by 2 and 3 if and only if it is divisibleby 6. Thus,

    A B =< lcm(2, 3) >=< 6 >, |A B| = 2102/6 = 350A C =< lcm(2, 5) >=< 10 >, |A C| = 2102/10 = 210B C =< lcm(3, 5) >=< 15 >, |B C| = 2102/15 = 140

    A B C =< lcm(2, 3, 5) >=< 30 >, |A B C| = 2102/30 = 70Consequently, by the inclusion-exclusion principle,

    |A B C| = |A| + |B| + |C| |A B| |A C| |B C| + |A B C|= 1051 + 700 + 420 350 210 140 + 70= 1, 541

    Note: The principle of inclusion-exclusion can be generalized to a finite number of sets. Thiscan be proved by using mathematical induction.

    Question 2.1.4. Generalize the above formula for four sets.

    Question 2.1.5. Find the number of positive integers less than or equal to 500 and are

    (i). divisible by 3

    (ii). divisible by 5

    (iii). divisible by 7

    (iv). divisible by 3 and 5

    (iv). divisible by 3 and 7 or 5

    (iv). neither divisible by 3 nor divisible by 7.

    2.1.5 Pigeonhole Principle

    Ifn pigeonholes are occupied by n +1 or more pigeons, then at leat one pigeonhole is occupiedby more than one pigeon.

    The Pigeonhole Principle: Suppose there are n pigeons, k pigeonholes, and n > k. If

    these n pigeons fly into these k pigeonholes, then some pigeonhole must contain at least twopigeons.

    Notice that the pigeonhole principle only tells us that an object with the desired propertyexists. It does not tell us which object has the desired property or how to find that object.

    The pigeon principle is also known as the Direchlet drawer principle, or the shoebox prin-ciple. This principle was first formally stated by Peter Gustave Lejeune Dirichlet (1805-1859).

    In order to apply the pigeonhole principle, we need to specify which objects are pigeons andwhich objects are pigeonholes.

    Let us consider the following problems:

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    12/32

    2.1 Basic Counting Principles 12

    Example 2.1.9. There are 13 people in a room. At least 2 of these 13people must be born inthe same month.Here we can think of months as pigeonholes and people in the room as pigeons. Then, becausethere are 13 people, n = 13. Similarly, because there are 12 months in a year, k = 12.Therefore, n = 13 > 12 = k. Because n > k, by the pigeonhole principle, at leat 2 people must

    be born in the same month.

    Example 2.1.10. Sometimes airlines hoping for cancelation, overbook flights. If 101 peopleare booked for a trip and the plane has only 100 seats then at least 2 people must be assignedthe same seat.

    Here the seats are the pigeonholes and the passengers holding the seats as pigeons. Thenn = 101, and k = 100. Because n > k, by the pigeonhole principle, at least 2 people must beassigned the same seat.

    Example 2.1.11. A student must take five classes from classes from three areas of study.Numerous classes are offered in each discipline, but the student cannot take more than two

    classes in any given area. Using the inclusion - exclusion principle, show that the students willhave to take at least one class in each area.

    Generalized Pigeonhole Principle:

    Suppose that there are n pigeons k pigeonholes, n > k, and m = nk. If these n pigeons fly

    into these k pigeonholes, then some pigeonholes must contain at least m pigeons.

    Example 2.1.12. Suppose there are 50 people in a room. Find the minimum number ofpeople that must have their birthday in the same month.

    Solution. We can think of the people as pigeons and the months as pigeonholes. Then n = 50,

    k = 12, and

    m = 5012

    = 5By the generalized pigeonhole principle, at least 5 people must have their birthday in the samemonth.

    Question 2.1.6. There are 400 students in a programming class. show that at least two ofthem were born on the same day of a month.

    n = 400, k = 30 days.

    m =

    n

    k =

    400

    12 Question 2.1.7. Suppose there is a group of 10 senators. Each senator must serve in one ofeight committees. Show that there is at least one committee with more than one senator.

    Question 2.1.8. From the integer in the set {1, 2, , 20}, what is the least number ofintegers that must be chosen so that at least one of them is divisible by 4?

    Question 2.1.9. In a group of 38 people, at least how many must have been born in the samemonth?

    Question 2.1.10. A group of 40 students in a class must show a set of 15 computers. Toavoid conflict, each student is assigned only one computer. Moreover, no computer is assigned

    to more than 4 students. Prove that at least 2 computers are assigned to 3 or more students.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    13/32

    2.2 Permutation and Combinations 13

    2.2 Permutation and Combinations

    2.2.1 Factorial Notation

    The product of the positive integers from 1 to n inclusive is denoted by n! (read as n factorial):

    n! = n (n 1) (n 2) 3 2 1e.g 5! = 5 4 3 2 1 and 0! = 1.Note: n cannot take negative values.

    2.2.2 Permutations

    A permutation is an ordered arrangement to every or some elements of a set of objects. Orderis important in a permutation, therefore permutations with the same objects in a differentorder are considered distinct arrangements. Some of the objects in the set, as well as in apermutation, may be indistinguishable from one another.

    A permutation of n distinct objets taken r at a time is a subset, with r elements, of then distinct objects. The number of these subsets denoted by nPr is equal to

    P(n, r) = nPr =n!

    (n r)! = n(n 1)(n 2) (n r + 1)

    Note: P(n, n) = n!.

    Example 2.2.1. Given the letters A,B,C,D ,E,F and G, how many arrangements of theseseven letters taken 4 at a time do we have?

    Solution. Let n = 7 and r = 4, Thus;

    7P4 =7!

    (7 4)! =7!

    3!= 840 arrangements

    If all n distinct elements of a set are to be arranged, then each arrangement is a permutationof n distinct objects taken n at a time. The number of such permutations is

    nPn =n!

    (n n)! =n!

    0!= n!

    Example 2.2.2. In how many ways can we arrange the three letters A,B, and C in a row

    from left to right?Solution. Let n = 3 and r = 1, thus;

    3P3 = 3! = 6 ways

    Question 2.2.1. Three schools have teams of six or more runners in a cross country race. Inhow many ways can the first six places be taken by the three schools, if there is no dead heats?

    Solution. Here, for all schools

    3 3 3 3 3 3 = 36 ways

    The first 6 places may be taken by the three schools.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    14/32

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    15/32

    2.2 Permutation and Combinations 15

    Example 2.2.7. How many even numbers greater than 2,000, can be formed with the digits1, 2, 4, and 8, if each digit may be used only once in each number?

    3 2 2 1 = 12 (without repetition of numbers).Example 2.2.8. Five letters from the word DRILLING are arranged in a row. Find the

    number of ways in which this can be done, when the first letter is I and the last is L,

    a). If no letter may be repeated

    b). If each letter may occur as many times as it does in DRILLING.

    Solution. Here we have the first and the last letters fixed. Only the middle digits can takedifferent letters.

    1st letter 2nd 3rd 4th 5thI 4 3 2 L

    Hence 4 3 2 = 24 ways.

    1st letter 2nd 3rd 4th 5thI 6 5 4 L

    Hence 5 5 4 = 120 ways.

    Example 2.2.9. In a hockey match, the game(match) can won, drawn or lost. If a team playsfive matches, how many different sequences of results are possible.

    Solution. The first match has 3 possible outcomes (win, draw, or lose). Similarly all the othermatches have 3 possible outcomes.

    3 3 3 3 3 = 35 = 243Example 2.2.10. How many different six figure phone numbers are possible if the digits 0 to9 are allowed, except that the first digit must be 7, 8, or 9?

    Solution. Here:

    Telephone number has 6 digits1st number can have only three possible choices.Each of the others has ten possible choices.

    Digit: First Second Third Fourth Fifth SixthNo. of Choices: 3 10 10 10 10 10

    Hence the total number of possible outcomes is

    3 105 = 300, 000Example 2.2.11. A car registration in the country of Burania consists of three letters, followedby three digits. The first letter is always A, and the other two letter should not include A, I,or O and must be different. The first digit must not be zero, but otherwise any digits may beused in any of the three places. How many different registrations are there?

    Solution. Setting out the possibilities, we have

    Letters DigitsFirst Second Third First Second Third

    1 23 22 9 10 10

    So altogether there are

    1 23 22 9 10 = 455, 400 different registrations.Example 2.2.12. In how many ways can 11 books be arranged on a shelf.

    11! = 39, 916, 800.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    16/32

    2.2 Permutation and Combinations 16

    Exercises

    1. How many five-digit odd numbers can be made from the digits 1, 2, 3,4, 5 if no digit isrepeated?

    2. How many numbers between 3,000 and 4,000, with distinct digits, can be formed usingthe digits 1, 3, 4, 5, and 6?

    3. Determine the four-digit numbers, with distinct digits, that can be formed using thedigits 0, 1, 2, 3, 4, 5, and 6 such that none of the numbers have a leading 0.

    4. Find the number of six-letter words that can be formed from the letters of the wordHISTORY if no letter is used more than once in any word subject to the conditionsgiven below:

    (a). The first letter of each word is H.

    (b). The first letter of each word is either H or Y.

    (c). The word starts with HIS.

    (d). The word contains HIS as a substring.

    5. In how many ways can four letters of the word BRIDGE be arranged in a row, if nowletter is repeated?

    6P4 =6!

    (6 4)! =6!

    2!= 360 ways.

    Alternatively

    Letter 1st 2nd 3rd 4thNo. of letters: 6 5 4 3

    Hence 6 5 4 3 = 360 ways.

    6. The computer department in a large company assigns a personal code number to eachemployee in the form of a three-digit number, using the digits 0 to 9 inclusive. Codenumbers starting with 0 are reserved for members of the management. How many codenumbers are available for non-management employees?

    7. A student has two coats, four scarves, and three pairs of shoes. How many differentoutfits, consisting of coat, scarf and a pair of shoes, can she make out of these.

    2 4 3 = 24 different outfits

    8. Four men and their wives sit on a bench. In how many ways can they be arranged if

    (a) there is no restriction,

    (b) each man sits nest to his wife?

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    17/32

    2.2 Permutation and Combinations 17

    2.2.3 Combinations

    LetS be a set with n > 0 elements. Let r be an integer such that 0 r n. An r-combinationof S or a combination of the elements of S taken r at a time is a subset A of S such that Acontains r elements of S.

    A combination of n distinct objects taken r at a time is a subset of the n objects with relements. A combination essentially creates a partition of the n objects into two cells, withr objects in the first cell and (n r) objects in the second cell. Therefore, the number ofcombinations of n distinct objects taken r at a time is

    C(n, r) =

    n

    r

    = NCr =

    n!

    r!(n r)!C(n, r) =

    P(n, r)

    P(r, r)

    Note: Unlike a permutation, a combination does not take order into account.

    Theorem 2.2.1. LetS be a set with n > 0 elements. Let r be an integer such that 0 r n.Then

    C(n, r) = C(n, n r).Proof.

    C(n, n r) = n!(n r)!(n (n r))!

    =n!

    (n r)!(n n + r)!=

    n!

    r!(n

    r)!

    = C(n, r).

    Theorem 2.2.2. Suppose there is a collection of n objects of k different types. Assume thatobjects of the same type cannot be distinguished from each other. Suppose each type containsni objects, i = 1, 2, , k, (n = n1 + n2 = n3 + + nk). Then the total number of differentarrangements of these n objects of k different types taken all at a time is:

    C(n, n1) C(n n1, n2) C(n n1 n2, n3) C(n n1 n2 nk1, nk),which equals

    n!

    n1!n2! nk1!nk!Each of the n!

    n1!n2! nk1!nk! is called a generalized arrangement, or generalized permutation,of the n objects of k different types taken all at a time.

    Theorem 2.2.3. Let n and r be two positive integers such that r n. Then the number ofr-combinations of n objects with repetitions allowed is

    C(n 1 + r, r).Example 2.2.13.

    8C5 =8!

    5!(8 5)! =8!

    5!3!

    Question 2.2.2. Suppose a candy shop has six different varieties of candy. Kamau wants to

    buy four candies. We want to know the number of ways Kamau can do this.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    18/32

    2.2 Permutation and Combinations 18

    Exercises

    1. In how many ways can 13 cards be selected from a pack of 52 playing cards?

    52C13 =52!

    39!13!

    2. A mixed hockey team containing 5 men and 6 women is to be chosen from 7 men and 9women. In how many ways can this be done?

    7C5 9 C6 = 7!2!

    5! 9!3!

    6! = 21 84 = 1764 ways

    3. A party of twelve is to dine at three tables at a hotel. In how many ways may they besplit if each table holds four?

    4. Twelve people are to travel by three cars, each of which holds four. Find the number ofways in which the party may be divided if two people refuse to travel in the same car.

    5. A ferry which holds ten people carries a party of thirteen men and seven women across ariver. Fund the number of ways in which the party may be taken across if all the womengo on the first trip.

    6. In a game of mixed hockey there are ten married couples and two spinsters playing. Inhow many ways can the two teams be made up, if no husband may play against his wife?

    7. Nine people are going to travel in two taxis. The larger has five seats, and the smallerhas four. In how many ways can the party be split up?

    8. How many mixed hickey teams may be made from six married couples, one bachelor and

    three spinsters, if no wife will play without her husband?

    9. The computer department in a large company assigns a personal code number to eachemployee in the form of a three-digit number, using the digits 0 to 9 inclusive. Codenumbers starting with 0 are reserved for members of the management. How many codenumbers are available for non management employees?

    10. Twelve people are to travel by three cars, each of which holds four. Find the number ofways in which the party may be divided if two people refuse to travel in the same car.

    11. In how many ways can a customer at the supermarket select three different types of sodafrom thirty available types, and ten different packets of biscuits from twelve different

    available packets?

    12. A man, who works a five-day week, can travel to work on foot, by cycle or by bus. Inhow many ways can he arrange a weeks traveling to work. 35 = 243 ways.

    13. Seven men and six women are to be seated in a row on a platform. In how many wayscan they be arranged if no two men sit next to each other? In how many ways can thearrangement be made if there are six men and six women, subject to the same restrictions.

    14. A man stays three days at a hotel and the menu is the same for breakfast each day.He may have any one of three types of egg dish, or two types of fish, or meat. In howmany ways can he order his three breakfast if he does not have eggs two days running

    (consecutively) nor repeat any dish?

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    19/32

    2.2 Permutation and Combinations 19

    15. Find the number of ways in which the letters of ISOSCELES can be arranged if the twoEs are separated.

    16. There are six contestants for the post of chairman, secretary and treasurer. These posi-tions can be filled by any of the 6. Find the possible number of ways in which the three

    positions may be filled.

    The number of ways of filling the three positions are 6 5 4 = 120 ways. Alternatively,

    6P3 =6!

    (6 3)! =6!

    3!= 120 ways

    17. In how many ways can a committee consisting of three men and two women be chosenfrom seven men and five women?

    18. The computer department in a large company assigns a personal code number to eachemployee in the form of a three-digit number, using the digits 0 to 9 inclusive. Code

    numbers starting with 0 are reserved for members of the management. How many codenumbers are available for non management employees?

    19. Twelve people are to travel by three cars, each of which holds four. Find the number ofways in which the party may be divided if two people refuse to travel in the same car.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    20/32

    Chapter 3

    Relations

    Introduction

    Relations are a natural way to associate objects of various sets. For example, we can take the

    set, say A, of people in a town and the set, say B, of businesses in that town. We can say thatan element a of A is related to an element b of B, if a is an employee of b.

    As another example, we can take the set F of farmers and the set V of vegetables. Wecan relate the elements ofF to the elements of V by defining that an element a of F is relatedto an element b of V if a grows b. The obvious question is how to represent relations in math-ematics.

    A binary relation, or simply a relation, R from a set A into a set B is a subset of A B.

    Let R be a relation from A into B, i.e., R A B. If (a, b) R, we say that, a is R-related; if the relation under consideration is understood) to b and write aRb (or, R(a) = b).If (a, b) R, i.e., if a is not R-related to b, we denote it by aRb.

    Product Set

    Consider the arbitrarily sets A and B. The set of all ordered pairs (a, b) where a A andb B is called the product, or cartesian product of A and B.

    A B = {(a, b) : a A and b B}Example 3.0.14. Let A = {1, 2} and B = {a,b,c}. Then

    A

    B =

    {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)

    }B A = {(a, 1), (b, 1), (c, 1), (a, 2), (b, 2), (c, 2)}A A = {(1, 1), (1, 2), (2, 1), (2, 2)}

    Note: A B = B AThe cartesian product deals with ordered pairs, so naturally the order in which the sets areconsidered is important.

    Using n(S) for the number of elements in a set S, we have

    n(A

    B) = 6 = 2

    3 = n(A)

    n(B).

    In fact n(A B) = n(A) n(B) for any finite sets A and B.

    20

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    21/32

    3.1 Binary Relations 21

    Example 3.0.15. Let S = {2, 3, 5, 6}, R means divides. State which pairs are related.2R2, 2R6, 3R3, 3R6, 5R5, 6R6

    Example 3.0.16. Let S = {1, 2, 3, , 20}, R =is three times,

    3R1, 6R2, 9R3, 12R4, 15R5, 18R6

    Example 3.0.17. R = {(x, y) : 2x y = 6, x R}. Determine three members of R.(4, 2), (0, 6), (1, 4)

    Find three more(2, 10), (3, 0), (2, 2)

    Example 3.0.18. LetA = {Kisumu, Garissa, Nyeri, Kakamega, Nakuru}B = {Central, Rift-Valley, Nyanza, North-Eastern, Western}

    Let x A and y B. Define the relation between x and y by x is the headquarter ofy.

    Using the relation, we can make the following ordered pairs: (Kisumu, Nyanza), (R.V, Nakuru),(Kakamega, Western), (Garissa, N.E).

    3.1 Binary Relations

    Any relation R on a set S, between two members of S is known as a binary relation on Sand is a subset of S S.Example 3.1.1. Let

    (a). S = {2, 3, 5, 6}, R means divides. State which pairs are related.2R2, 2R6, 3R3, 3R6, 5R5, 6R6

    (b). S = {1, 2, 3, , 20}, and R = is three times. List the relations that are valid3R1, 6R2, 9R3, 12R4, 15R5, 18R6,

    (c). R = {(x, y) : 2x y = 6, x R}. Determine three members of R.

    (4, 2), (0, 6), (1, 4), (2, 10), (3, 0), (2, 2)3.1.1 Properties of Binary Relations

    Reflexive relations

    A relation R on a set S is called reflexive whenever aRa for every a S.Example 3.1.2. Let

    (a). On the set of all triangles in a plane, say T, Let R = is congruent to

    So R is reflexive.

    For all t T, t T, tRt so R is reflexive.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    22/32

    3.1 Binary Relations 22

    (b). For some set T let R =has twice the area of is R reflexive?

    Clearly R is not reflexive.

    (c). Consider the following five relations on the set A = {1, 2, 3, 4}.

    R1 = {(1, 1), (1, 2), (2, 3), (1, 3), (4, 4)}R2 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}R3 = {(1, 3), (2, 1)}R4 = , the empty relation.R5 = A A, the universal relation.

    Determine which of the relations are reflexive.

    Solution. Only R2 and the universal relation R5 = A A are reflexive.

    Note: R1, R3 and R4 are not reflexive since, for example (2, 2) doesnt belong to any of them.

    Symmetric relations

    A relation R on a set S is called symmetric if whenever aRb then bRa; that is, if whenever(a, b) R then (b, a) R. Thus R is not symmetric if there exists a, b A such that (a, b) Rbut (b, a) not in R.

    From the example above, determine which of the relations are symmetric.

    R1 is not symmetric since, (1, 2) R1, but (2, 1) not in R1.R3 is not symmetric since (1, 3) R3 but (3, 1) not in R3.

    The other relations are symmetric.

    Antisymmetric relations

    A relation R on a set A is antisymmetric if whenever aRb and bRa then a = b, that is, ifwhenever (a, b), (b, a) R then a = b.

    Thus R is not antisymmetric if there exists a, b A such that (a, b) and (b, a) belong toR, but a = b.From the above example,

    R2 is not antisymmetric since (1, 2) and (2, 1) belong to R2, but 1 = 2.

    Similarly, the universal relation R5 is not antisymmetric.

    All the other relations are antisymmetric.Note: The properties of being symmetric and being antisymmetric are not negative of eachother.

    For example, the relation R = {(1, 3), (3, 1), (2, 3)} is neither symmetric nor antisymmetric.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    23/32

    3.1 Binary Relations 23

    On the other hand, the relation R = {(1, 1), (2, 2)} is both symmetric and antisymmetric.

    Transitive relations

    A relation R on a set A is transitive if whenever aRb and bRc then aRc, that is, if whenever(a, b), (b, c) R then (a, c) R. Thus R is not transitive if there exists a,b,c a such that(a, b), (b, c) R but (a, c) is not in R.

    For the above example, determine which of the relations are transitive.

    The relation R3 is not transitive, since (2, 1), (1, 3) R3 but (2, 3) is not in R3.Example 3.1.3. Let S be the set of all lines in a plane and R =is parallel to. Is R transitive?

    If aRb, bRc, and aRc, then R is transitive.

    Example 3.1.4. For the same set S, R =is perpendicular to. Is R transitive?

    If aRb and bRc the C is parallel to a, so we do not have aRc. Hence R is not transitive.

    Equivalence Relations

    Let A be a set and let R be a relation on A. Then R is called

    (i). reflexive, if for all a A, aRa;(ii). symmetric, if for a, b, c A, whenever aRb and bRa must also hold;

    (iii). transitive, if all a,b,c

    A, whenever aRb and bRc hold, aRc must also hold.

    Let A be a set and let R be a relation on A. Observe that

    R is not reflexive, if there exists a, b A such that (a, a) is not in R; R is not symmetric, if there exists a, b A such that (a, b) R, but (b, a) not in R. R is not transitive, if there exists a,b,c A such that (a, b) R, (b, c) R but (a, c)

    not in R.

    A relation R on a set A is called an equivalence relation if R is reflexive, symmetric, andtransitive.

    Example 3.1.5. Let A = {a,b,c,d} and R = {(a, b), (b, b), (c, c), (d, d), (a, b), (b, a)}. Showthat R is an equivalence relation on A.

    Theorem 3.1.1. Let R be a relation on a set A. ThenR is an equivalence relation on A ifand only if

    (i). A R, where A = {(a, a)|a A}.(ii). R = R1, and (Inverse)

    (iii). R R R (composition)

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    24/32

    3.1 Binary Relations 24

    Example 3.1.6. Confirm that the relation is equal to on a set of real numbers is an equiv-alence relation.

    x = xx R hence reflexivex = y y = xx R symmetricalx = y = z x = zx R transitive.The relation is an equivalence relation.

    Example 3.1.7. Is the relation has the same surname as on the set p of people in the blockof flats in Kingongo an equivalence relation?

    Proof. (i). x has the surname as x so reflexive.

    (ii). x has the same surname as y, then y has the same surname as x, so symmetric.

    (iii). If x has the same surname as y, y has the same surname as z. then x has the samesurname as z, the relationship is transitive.

    Each of the properties reflexive, symmetric, and transitive holds, so the relation is anequivalence relation on p.

    Question 3.1.1. On p is the relation is the sister of an equivalence relation?

    It is not an equivalence relation.

    Equivalence Classes and Partitions

    For any set let R be an equivalence relation on S. If a S, the set of elements y S whereyRa constitute a subset [a], of S is called an equivalence set or equivalence class.

    [a] = {y : y S,yRa}

    Let R be an equivalence relation on a set X. For all x X, let [x] denote the set

    [x] = {y X|yRx}

    The subset [x] of X is called the equivalence class (R-class, or R-equivalence class) of theequivalence relation R determined by x.

    The relation

    R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 4), (4, 1), (2, 3), (3, 2)}

    on the set A = {1, 2, 3, 4, 5} is an equivalence relation. The equivalence class [1] is the subsetof those elements of A that are related to 1. Because only 1R1 and 4R1, we have [1] = {1, 4}.Question 3.1.2. For the set T of triangles in a plane and R =is congruent to. Check if Ris an equivalence relation. Give an example of an equivalence class (equivalence set).

    The following theorems furnishes some fundamental properties of equivalence classes.

    Theorem 3.1.2. The set (A1, A2, An) of non empty subset of S will be called apartitionof set S provided

    (i). A1 A2 An = S and

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    25/32

    3.1 Binary Relations 25

    (ii). Ai Aj = for i = j,(i, j = 1, 2, , n)An equivalence relation R on a set S effects a partition of S and conversely a partition of

    S defines an equivalence relation on S.

    Example 3.1.8. On S consider R = has the same remainder when divided by 3, where

    S = {X : 1 x 25, x N}

    Show that R is an equivalence relation, and partitions S into subsets defined by R.

    Remainder 1 = {4, 7, 10, 13, 16, 19, 22, 25}Remainder 2 = {5, 8, 11, 14, 17, 20, 23}

    Symmetric and antisymmetric relations

    A relation R on a set A is symmetric if whenever aRb then bRa, that is, if whenever (a, b)

    R

    then (b, a) R. Thus R is not symmetric if there exists A, b A such that (a, b) R but (b, a)is not in R.

    A relation R on a set A is antisymmetric if whenever aRb and bRa then a = b, that is, ifwhenever (a, b), (b, a) R then a = b. Thus R is not antisymmetric if there exists a, b Asuch that (a, b) and (b, a) belong to R, but a = b.Note: The properties of being symmetric and being antisymmetric are not negatives of eachother. For example, the relation

    R = {(1, 3), (3, 1), (2, 3)}

    is neither symmetric nor antisymmetric. On the other hand, the relation

    R = {(1, 1), (2, 2)}

    is both symmetric and antisymmetric.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    26/32

    Chapter 4

    Recurrence Relations

    In this chapter, we look at examples illustrating recurrence relationships and discuss a methodfor solving recurrence relations. By solving a recurrence relation, we mean finding an explicitformula, a term we define, for the nth term.

    4.1 Sequences and Recurrence Relations

    A sequence is simply a list of objects arranged in a definite order; a first element, secondelement, third element, and so on. The list may stop after n steps, n N, or it may go onforever. In the first case we say that the sequence is finite, and in the second case we say thatit is infinite. The elements may all be different, or some may be repeated.

    Example 4.1.1. The sequence 1, 0, 0, 1, 0, 0, 1, 1, 1, is a finite sequence with repeateditems.

    Example 4.1.2. The list 3, 8, 13, 18, 23,

    is an infinite sequence.

    Example 4.1.3. Another infinite sequence is 1, 4, 9, 16, 25, , the list of the squares of allpositive integers.

    It may happen that how a sequence is to continue is not clear from the first few terms.Also, it may be useful to have a compact notation to describe a sequence.

    Two kinds of formulae are commonly used to describe sequences.

    Example ??: Adding 5 to the previous term

    a1 = 3, an = an1 + 5, 2 nA formula, like this that refers to previous terms to define the next term is called recursive.Every recursive formula must include a starting place.

    On the other hand, in Example ?? it is easy to describe a term using only its positive number.In the nth position is the square of n; bn = n

    2, n 1. This type of formula is called explicit,because it tells us exactly what value any particular term has.

    Example 4.1.4. The recursive formula c1 = 5, cn = 2cn1, 2 n 6, defines the finitesequence 5, 10, 20, 40, 80, 160.

    Example 4.1.5. The infinite sequence 3, 7, 11, 15, 19, 23, can be defined by the recursive

    formula d1 = 3, dn = dn1 + 4.

    26

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    27/32

    4.1 Sequences and Recurrence Relations 27

    Example 4.1.6. The explicit formula sn = (4)n, n 1, describes the infinite sequence

    4, 16, 64, 256,

    Example 4.1.7. The finite sequence 87, 82, 77, 72, 67 can be defined by the explicit formula

    tn = 92 5n, 1 n 5

    Question 4.1.1. Write a formula for the nth term of the sequence. Identify your formula asrecursive or explicit.

    (a). 1, 3, 5, 7 (b). 0, 3, 8, 15, 24, 35, (c). 1, 1, 1, 1, 1, 1, (d). 0, 2, 0, 2, 0, 2, (e). 1, 4, 7, 10, 13, 16, (f). 1, 1/2, 1/4, 1/8, 1/16, (g). 1, 3, 5, 9, 17, 31, 57, 105, (h). 7, 17, 27, 37, 47, 57, , 67, (i). 1, 1, 2, 6, 24, 120, 720, (j). 2, 4, 5, 7, 7, 9, 12, 16, 22,

    Question 4.1.2. Write an explicit formula for the sequence 2, 5, 8, 11, 14, 17,

    .

    Question 4.1.3. Write a recursive formula for the sequence 2, 5, 7, 12, 19, 31, .Example 4.1.8. Consider the following two sequences:

    S1 : 3, 5, 7, 9, S2 : 3, 9, 27, 81,

    We can find a formula for the nth term of sequence S1 and S2 by observing the pattern ofthe sequences.

    S1 : 2

    1 + 1, 2

    2 + 1, 2

    3 + 1, 2

    4 + 1,

    S2 : 31, 32, 33, 34,

    For S1, an = 2n + 1, for n 1, and for S2, an = 3n for n 1. This type of formula is calledan explicit formula for the sequence, because using this formula we can directly find anyterm of the sequence without using other terms of the sequence. For example, a3 = 23+1 = 7.

    In the preceding example, it was easy to find an explicit formula for the nth term of thesequence. However, there are sequences for which finding an explicit formula is not obvious.Let us consider the following example.

    Let S denote the sequence.

    1, 1, 2, 3, 5, 8, 13, 21,

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    28/32

    4.1 Sequences and Recurrence Relations 28

    For this sequence, the explicit formula is not obvious. If we observe closely, however, we findthat the pattern of the sequence is such that any term after the second term is the sum of thepreceding two terms. Now

    3 rd term = 2 = 1 + 1 = 1 st term + 2 nd term

    4 th term = 3 = 1 + 2 = 2 nd term + 3 rd term5 th term = 5 = 2 + 3 = 3 rd term + 4 th term

    6 th term = 8 = 3 + 5 = 4 th term + 5 th term

    Hence, the sequence S can be defined by the equation

    fn = fn1 + fn2

    for all n 3 andf1 = 1

    f2 = 1

    This sequence is called the Fibonacci sequence in honor of the Italian mathematicianLeonardo Fibonacci, and the terms of the sequence are called Fibonacci numbers. We seethat we can find the nth term, n 3, of the sequence from the preceding two terms. Noticethat the values of f1 and f2 are given explicitly. Now because

    f3 = f1 + f2,

    using f1 and f2, we can determine f3. Similarly, we have.

    f4 = f2 + f3.

    Therefore, using f2 and f3, we can determine f4, and so on.

    Because fn is defined in terms of previous terms of the sequence, equations of the form.

    fn = fn1 + fn2

    are called recurrence equations of recurrence relations.

    A recurrence relation for a sequence a0, a1, a2, , an, is an equation that re-lates an to some of the terms a0, a1, a2, , an2, an1 for all integers n with n k, wherek is a nonnegative integer. The initial conditions for the recurrence relations are a set ofvalues that explicitly define some of the members of a0, a1, a2, , ak1.

    For the Fibonacci sequence f1 = 1, f2 = 1 gives the initial conditions.

    The equation an = 2an1 + an2 for all n 2 as defined relates an to an1 and an2. Herek = 2, so this is a a recurrence relation with initial conditions a0 = 5 and a1 = 7.

    Example 4.1.9. Consider the function defined by f(0) = 1, f(n) = nf(n 1) for all n 1.

    Then

    f(0) = 1 = 0!,

    f(1) = 1 f(0) = 1 = 1!f(2) = 2

    f(1) = 2

    1 = 2 = 2!

    f(3) = 3 f(2) = 3 2 1 = 6 = 3!

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    29/32

    4.1 Sequences and Recurrence Relations 29

    and so on.

    Here f(n) = nf(n 1) for all n 1 is the recurrence relation, and f(0) = 1 is the initialcondition for the function f. Notice that the function f is nothing but the factorial function,i.e., f(n) = n! for all n 0.Example 4.1.10. Compound interest. Sam received a yearly bonus and deposited $10,000 ina local bank yielding 7% interest compounded annually. Sam wants to know the total amountaccumulated after n years.

    Solution. Let An denote the total amount accumulated after n years. Let us determine arecurrence relation and initial conditions for the sequence A0, A1, A2, ; A3. .

    The amount accumulated after one year is the initial amount plus the interest on the ini-tial amount. Now An1 is the amount accumulated after n 1 years. This implies that theamount at the beginning of nth year is An1. If follows that the total amount accumulatedafter n years is the amount at the beginning of the nth year plus the interest on this amount.

    Because the interets rate is 7%, the interets earned during the nth year is

    (0.07)An1.

    Hence

    An = An1 + 0.07An1

    = 1.07An1, n 1A0 = 10, 000

    Thus, we find that a recurrrence relation and initial condition for the sequence {An}n=0 are

    An = 1.07An

    1, n 1, A0 = 10, 000.Example 4.1.11. Tower of Hanoi. In the nineteenth century, a game called Tower of Hanoibecame popular in Europe. This game represents work that is under way in the temple ofBrahma. At the creation of the universe, priests in the temple of Brahma were supposedlygiven three diamond pegs, with one peg containing 64 golden disks. Each golden disk is slightlysmaller than the disk below it. The preiests task is to move all 64 disks from the first peg tothe third peg. the rules for moving the disks are as follows:

    1. Only one disk can be moved at a time.

    2. The removed disk musk be placed on one of the pegs.

    3. A larger disk cannot be placed on top of a smaller disk.

    The priests were told that once they had moved all the disks from the first peg to the thirdpeg, the universe would come to an end.

    Our objective is to determine the minimum number of moves required to transfer the disksfrom the first peg to the third peg.

    In general, let peg 1 contain n 1 disks.1. Move the top (n 1) disks from peg 1 to peg 2 using peg 3 as the intermediate peg.

    2. Move disk number n from peg 1 to peg 3.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    30/32

    4.2 Solving Recurrence relations by Iterations (Substitution) 30

    3. Move the top n 1 disks from peg 2 to peg 3 using peg 1 as the intermediate.Let cn denote the number of moves required to move n disks, n 0, from peg 1 to peg 3. Step(n) requires us to move the top n1 disks from peg peg 1 to peg 2, which requires cn1 moves.Step (2) requires us to move the nth disk from peg 1 to peg 3, which requires 1 move. Step

    (3) requires us to move (n 1) disks from peg 2 to peg 3 which requires cn1 moves. Thus, itfollows that cn = 2cn1 + 1 if n > 1 and c1 = 1.

    Now the above is a recurrence relation for the sequence {cn}n=1 with the initial conditiongiven by c1 = 1.

    Example 4.1.12. Rabbits on an Island. The following problem was proposed by LeonardoFibonacci in the thirteenth century in his book Liber abaci.

    A pair of newborn rabbits (one male and one female) is kept on an island where there areno other rabbits. A pair of rabbits does not breed until they are two months old. After apair becomes two months old, each pair of rabbits (of opposite sexes) produce another pair (of

    opposite sexes) each month. Assuming that no rabbits ever die, find a recurrence relation forthe number of pairs of rabbits on the island just after n months.

    Solution. Let an denote the number of pairs of rabbits on the island just after n months. Atthe end of the first moth, the number of pairs of rabbits on the island is

    a1 = 1

    This pair of rabbits does not breed during the second month. Thus, the number of pairs ofrabbits just after the second month is

    a2 = 1.

    Now the number of pairs of rabbits, an, just after n months is the number of pairs after n

    1months plus the number of newborn pairs in the nth month. The number of newborn pairsin the nth month is the number of pairs just after the (n 2)th month because each newbornpair is produced by a pair of rabbits at least two months old. Hence,

    an = an1 + an2, n 3.which is a recurrence relation. The initial condition are a1 = 1 and a2 = 1. Now

    a3 = a2 + a1 = 1 + 1 = 2,

    a4 = a3 + a2 = 2 + 1 = 3,

    a5 = a

    4 + a3 = 3 + 2 = 5,

    and so on. We see that the sequence defined above is

    1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, which is the Fibonacci Sequence.

    4.2 Solving Recurrence relations by Iterations (Substitution)

    Our goal in solving a recurrence relation is to find an explicit formula for the general terman of the recurrence relation. In this section, we describe how to find an explicit formula by

    iteration, or substitution.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    31/32

    4.2 Solving Recurrence relations by Iterations (Substitution) 31

    Suppose a recurrence relation for a sequence a0, a1, a2, , an, , is given. By a solu-tion of the recurrence relation we mean to obtain an explicit formula for an, i.e., to findan expression for an that does not involve any other ai, i = n 1, n 2, .

    When the problem is to find an explicit formula for a recursively defined sequence, the recur-

    sive formula is called a recurrence relation. Remember that to define a sequence recurssively,a recursive formula must be accompanied by information about the beginning of the sequence.This information is called the initial condition or conditions for the sequence.

    (a). The recurrence relation an = an1 + 3 with a1 = 4 recursively defines the sequence4, 7, 10, 13, .

    (b). The recurrence relation fn = fn1 + fn2, f1 = f2 = 1 defines the Fibonacci sequence

    1, 1, 2, 3, 5, 8, 13, 21, .

    The initial conditions are f1 = 1 and f2 = 1.

    Recurrence relations arise naturally in many counting problems and in analyzing programmingproblems.

    Example 4.2.1. The recurrence relation an = an1 + 3 with a1 = 2 defines the sequence2, 5, 8, . We backtrack the value of an b ysubstituting the definition of an1, an2, and soon until a pattern is clear,

    an = an1 + 3

    = (an2 + 3) + 3 = an2 + 2 3= ((an3 + 3) + 3) + 3 = an3 + 3 3

    Eventually this process will produce

    an = an(n1) + (n 1) 3= a1 + (n 1) 3= 2 + (n 1) 3

    An explicit formula for the sequence is

    an = 2 + (n 1)3

    Example 4.2.2. Let S be the sequence {an}n=0, where an = 7an1 6an2 for all n 2.Because an is defined in terms of the preceding terms an1 and an2, the equation above is arecurrence relation.

    Let us show that an = 5 = 5 + 0 n is a solution of the equation above. Here a0 = 5,a1 = 5, a2 = 5, , an = 5, and so on. Let us evaluate the RHS of the equation, i.e.,

    7an1 6an2 = 7 5 6 5 = 35 30 = 5 = a5Hence an = 5, n 0 is a solution of the recurrence relation above.Example 4.2.3. Backtrack to find an explicit formula for the sequence defined by the recur-rence relation

    bn = 2bn1 + 1 with initial condition b1 = 7.

  • 8/3/2019 Discrete Structure I November 2010 Lecture Notes

    32/32

    4.2 Solving Recurrence relations by Iterations (Substitution) 32

    Solution. We begin b ysubstituting the definition of the previous term in the defining formula

    bn = 2bn1 + 1

    = 2(2bn2 + 1) + 1

    = 2[2(2bn3 + 1) + 1] + 1

    = 23bn3 + 4 + 2 + 1

    = 23bn3 + 22 + 21 + 1.

    A pattern is emerging with these rewrittings of bn. (Note: There are no set rules for how torewrite these expressions and a certain amount of experimentation may be necessary.)

    The backtesting will end at

    bn = 2n1bn(n1) + 2

    n2 + 2n3 + + 22 + 21 + 1= 2n1b1 + 2

    n1 1 (using mathematical induction)1 + 21 + 22 + + 2n = 2n+1 1.

    = 7 2n1 + 2n1 1 using b1 = 7= 8 2n1 1 or 2n+2 1.

    Recall the following

    1 + a + a2 + a3 + + an1 = an 1

    a 11 + 2 + 3 + + n = n(n + 1)

    2

    Backtracking may not reveal an explict pattern for the sequence defined a recurrence rela-tion. We now introduce a more general technique for solving a recurrence relation. First wegive a definition. A recurrence realtion is a linear homogeneous relation of degree k if itis of the form

    an = r1an1 + r2an2 + + rkank with the ris constants.

    Note that on the right-hand side, the summands are each built the same (homogeneeous) way,as a multiple of one of the k (degree k) previuos terms (linear).

    Example 4.2.4. Consider the following;

    (a). The relation cn = (

    2)cn1

    is a linear homogeneous recurrence relation of degree 1.

    (b). The relation an = an1 + 3 is not a linear homogeneous recurrence relation.

    (c). The recurrence relation fn = fn1 + fn2 is a linear homogeneous relation of degree 2.

    (d). The recurrence relation an = a2n1 + an2 is not a linear homogeneous relation.

    For a linear homogeneous recurrence relation of degree k, an = r1an1 + r2an2 + +rkank, we call the associated polynomial of degree k, x

    k = r1xk1 + r2x

    k2 + + rk itscharacteristic equation. The roots of the characteristic equation play a key role in theexplicit formula for the sequence defined by the recurrence relation and the initial conditions.While the problem can be solved in general, we give a theorem for degree 2 only. Here it is

    common to write the characteristic equation as x2 r1x r2 = 0.