46
786 Answers of Discrete_Mathematics Page No (186) Q1. Explain what it means for one set to be a subset of another set. How do you prove that one set is a subset of another set? A1: The set A is a subset of B if and only if every element of A is also an element of B. We use the notation A B to indicate that A is a subset of the set B. We see that A B if and only if the quantification x(x A → x B) is true. Note that to show that A is not a subset of B we need only find one element x A with x /B. Such an x is a counterexample to the claim that x A implies x B. We have these useful rules for determining whether one set is a subset of another: Showing that A is a Subset of B. To show that A B, show that if x belongs to A then x also belongs to B. Showing that A is Not a Subset of B. To show that A _B, find a single x A such that x _B. Q2. What is the empty set? Show that the empty set is a subset of every set. A2: The empty set is the set with no elements. It satisfies the definition of being a subset of every set vacuously. Q3. a) Define |S|, the cardinality of the set S. b) Give a formula for |A B|, where A and B are sets. A3: a) Showing Two Sets are Equal. To show that two sets A and B are equal, show that A B and B A. b) Sets may have other sets as members. For instance, we have the sets A = {, {a}, {b}, {a, b}} and B = {x | x is a subset of the set {a, b}}. Note that these two sets are equal, that is, A = B. Also note that {a} A, but a /A. Q4. a) Define the power set of a set S. b) When is the empty set in the power set of a set S? c) How many elements does the power set of a set S with n elements have? A4: a) Given a set S, the power set of S is the set of all subsets of the set S. The power set of S is denoted by P(S). b) Always c) 2 n Q5. a) Define the union, intersection, difference, and symmetric difference of two sets. b) What are the union, intersection, difference, and symmetric difference of the set of positive integers and the set of odd integers? A5:a) Union: Let A and B be sets. The union of the sets A and B, denoted by A B, is the set that contains those elements that are either in A or in B, or in both. An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongs to B. This tells us that (A B = {x | x A x B}). E.g. The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, {1, 3, 5} {1, 2, 3} = {1, 2, 3, 5}. Intersection: Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the set containing those elements in both A and B. An element x belongs to the intersection of the sets A and B if and only if x belongs to A and x belongs to B. This tells us that (A ∩ B = {x | x A x B}). E.g. The intersection of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 3}; that is, {1, 3, 5} ∩ {1, 2, 3} = {1, 3}. b) Union: integers that are odd or positive, intersection: odd positive integers, difference: even positive integers, symmetric difference: even positive integers together with odd negative integers

Answers of Discrete_Mathematics

Embed Size (px)

Citation preview

786

Answers of Discrete_Mathematics Page No (186)

Q1. Explain what it means for one set to be a subset of another set. How do you prove that one set is a subset of another set? A1: The set A is a subset of B if and only if every element of A is also an element of B. We use the notation A ⊆ B to indicate that A is a subset of the set B. We see that A ⊆ B if and only if the quantification ∀x(x ∈ A → x ∈ B) is true. Note that to show that A is not a subset of B we need only find one element x ∈ A with x /∈ B. Such an x is a counterexample to the claim that x ∈ A implies x ∈ B. We have these useful rules for determining whether one set is a subset of another: Showing that A is a Subset of B. To show that A ⊆ B, show that if x belongs to A then x also belongs to B. Showing that A is Not a Subset of B. To show that A _⊆ B, find a single x ∈ A such that x _∈B. Q2. What is the empty set? Show that the empty set is a subset of every set. A2: The empty set is the set with no elements. It satisfies the definition of being a subset of every set vacuously. Q3. a) Define |S|, the cardinality of the set S. b) Give a formula for |A ∪ B|, where A and B are sets. A3: a) Showing Two Sets are Equal. To show that two sets A and B are equal, show that A ⊆ B and B ⊆A. b) Sets may have other sets as members. For instance, we have the sets A = {∅, {a}, {b}, {a, b}} and B = {x | x is a subset of the set {a, b}}. Note that these two sets are equal, that is, A = B. Also note that {a} ∈ A, but a /∈ A. Q4. a) Define the power set of a set S. b) When is the empty set in the power set of a set S? c) How many elements does the power set of a set S with n elements have? A4: a) Given a set S, the power set of S is the set of all subsets of the set S. The power set of S is denoted by P(S). b) Always c) 2n

Q5. a) Define the union, intersection, difference, and symmetric difference of two sets. b) What are the union, intersection, difference, and symmetric difference of the set of positive integers and the set of odd integers? A5:a) Union: Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set that contains those elements that are either in A or in B, or in both. An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongs to B. This tells us that (A ∪ B = {x | x ∈ A ∨ x ∈ B}). E.g. The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, {1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}. Intersection: Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the set containing those elements in both A and B. An element x belongs to the intersection of the sets A and B if and only if x belongs to A and x belongs to B. This tells us that (A ∩ B = {x | x ∈ A ∧ x ∈ B}). E.g. The intersection of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 3}; that is, {1, 3, 5} ∩ {1, 2, 3} = {1, 3}. b) Union: integers that are odd or positive, intersection: odd positive integers, difference: even positive integers, symmetric difference: even positive integers together with odd negative integers

786

Q6. a) Explain what it means for two sets to be equal. b) Describe as many of the ways as you can to show that two sets are equal. c) Show in at least two different ways that the sets A − (B ∩ C) and (A − B) ∪ (A − C) are equal. A6: a) A= B = (A<:;;; B /\ B <:;;;A)= Vx(x EA+-+ x EB) b) If you want extra about this Question see book. Page no (129-132)

TABLE Set Identities.

Identity Name

A ∩ U = A A ∪ ∅ = A

Identity laws

A ∪ U = U A∩∅ = ∅

Domination laws

A ∪ A = A A ∩ A = A

Idempotent laws

(A) = A

Complementation law

A ∪ B = B ∪ A A ∩ B = B ∩ A

Commutative laws

A ∪ (B ∪ C) = (A ∪ B) ∪ C A ∩ (B ∩ C) = (A ∩ B) ∩ C

Associative laws

A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)

Distributive laws

A ∩ B = A ∪ B A ∪ B = A ∩ B

De Morgan’s laws

A ∪ (A ∩ B) = A A ∩ (A ∪ B) = A

Absorption laws

A ∪ A = U A ∩ A = ∅ Complement laws

c) An B n C =An (Bu C) = (An B) u (An C) = (A- B) u (A - C); use Venn diagrams Q7. Explain the relationship between logical equivalences and set identities. A7: Underlying each set identity is a logical equivalence. These follow directly from the corresponding properties for the logical operations or and and. a) AU B = { x I x E A V x E B} = { x I x E B V x E A} = B U A b) An B = { x Ix EA/\ x EB}= { x Ix EB /\ x EA}= B n A Q8. a) Define the domain, codomain, and range of a function. b) Let f (n) be the function from the set of integers to the set of integers such that f (n) = n2 + 1. What are the domain, codomain, and range of this function? A8: a) Z, Z, z+ = N - {O} b) If f is a function from A to B, we say that A is the domain of f and B is the codomain of f. If f (a) = b, we say that b is the image of a and a is a preimage of b. The range, or image, of f is the set of all images of elements of A. Also, if f is a function from A to B, we say that f maps A to B. Q9. a) Define what it means for a function from the set of positive integers to the set of positive integers to be one-to-one. b) Define what it means for a function from the set of positive integers to the set of positive integers to be onto.

786

c) Give an example of a function from the set of positive integers to the set of positive integers that is both one-to-one and onto. d) Give an example of a function from the set of positive integers to the set of positive integers that is one-to-one but not onto. e) Give an example of a function from the set of positive integers to the set of positive integers that is not one-to-one but is onto. f ) Give an example of a function from the set of positive integers to the set of positive integers that is neither one-to-one nor onto. A9: a) A function f is said to be one-to-one, or an injunction, if and only if f (a) = f (b) implies that a = b for all a and b in the domain of f.A function is said to be injective if it is one-to-one. b) A function f from A to B is called onto, or a surjection, if and only if for every element b ∈ B there is an element a ∈ A with f (a) = b.A function f is called surjective if it is onto. Remark: A function f is onto if ∀y∃x(f (x) = y), where the domain for x is the domain of thefunction and the domain for y is the codomain of the function. E.g1: Let f be the function from {a, b, c, d} to {1, 2, 3} defined by f (a) = 3, f (b) = 2, f (c) = 1, and f (d) = 3. Is f an onto function? Solution: Because all three elements of the codomain are images of elements in the domain, we see that f is onto. This is illustrated in Figure 4. Note that if the codomain were {1, 2, 3,4}, then f would not be onto. E.g2: Is the function f (x) = x2 from the set of integers to the set of integers onto? Solution: The function f is not onto because there is no integer x with x2 = −1, for instance. c) f(n) = n d) f(n) = 2n e) f(n) = f n/21 f) f(n) = 42548 Q10. a) Define the inverse of a function. b) When does a function have an inverse? c) Does the function f (n) = 10 − n from the set of integers to the set of integers have an inverse? If so, what is it? A10: a) Let f be a one-to-one correspondence from the set A to the set B. The inverse function of f is the function that assigns to an element b belonging to B the unique element a in A such that f (a) =b. The inverse function of f is denoted by f−1. Hence, f −1 (b) = a when f (a) = b. (f-1 (b) =a= f (a) = b) b) when it is one-to-one and onto c) yes-itself Q11. a) Define the floor and ceiling functions from the set of real numbers to the set of integers. b) For which real numbers x is it true that _x_ = _x_? A11: a) The floor function assigns to the real number x the largest integer that is less than or equal to x. The value of the floor function at x is denoted by _x_. The ceiling function assigns to the real number x the smallest integer that is greater than or equal to x. The value of the ceiling function at x is denoted by _x_. Remark: The floor function is often also called the greatest integer function. It is often denoted by [x]. E.g: These are some values of the floor and ceiling functions: [1/2]= 0, [1/2]= 1, [-1/2]= -1, [-1/2]= 0, [3.1]= 3, [3.1]= 4, [7] = 7, [7] = 7 We display the graphs of the floor and ceiling functions in Figure 10. In Figure 10(a) we display the graph of the floor function _x_. Note that this function has the same value throughout the interval

786

[n, n + 1), namely n, and then it jumps up to n + 1 when x = n + 1. In Figure 10(b) we display the graph of the ceiling function _x_. Note that this function has the same value throughout the interval (n, n + 1], namely n + 1, and then jumps to n + 2 when x is a little larger than n + 1. The floor and ceiling functions are useful in a wide variety of applications, including those involving data storage and data transmission. E.g: Data stored on a computer disk or transmitted over a data network are usually represented as a string of bytes. Each byte is made up of 8 bits. How many bytes are required to encode 100 bits of data? Solution: To determine the number of bytes needed, we determine the smallest integer that is at least as large as the quotient when 100 is divided by 8, the number of bits in a byte. Consequently, [100/8] = [12.5] = 13 bytes are required. b) Integers Q12. Conjecture a formula for the terms of the sequence that begins 8, 14, 32, 86, 248 and find the next three terms of your sequence. A12: Hint: subtract 5 from each term and look at the resulting sequence. Q13. Suppose that an = an−1 − 5 for n = 1, 2, ... Find a formula for an. A13: The formula depends on the initial condition, namely the value of a0 . After that, each term is 5 less than the preceding term, so an = ao - 5n.

Q14. What is the sum of the terms of the geometric progression a + ar +・ ・ ・+arn when r _= 1? A14: Q15. Show that the set of odd integers is countable. A15: Set up a one-to-one correspondence between the set of positive integers and the set of all odd integers, such as 1 ++ 1, 2 ++ 1, 3 ++ 3, 4 ++ 3, 5 ++ 5, 6 ++ 5, and so on.

Answer of (232) number page

Q1. a) Define the term algorithm. b) What are the different ways to describe algorithms? c) What is the difference between an algorithm for solving a problem and a computer program that solves this problem? A1: a) An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem. b) In English, In a computer language, In pseudocode c) An algorithm is more of an abstract idea-a method in theory that will solve a problem. A computer program is the implementation of that idea into a specific syntactically correct set of instructions that a real computer can use to solve the problem. It is rather like the difference between a dollar (a certain amount of money, capable in theory of purchasing a certain quantity of goods and services) and a dollar bill. Q2. a) Describe, using English, an algorithm for finding the largest integer in a list of n integers. b) Express this algorithm in pseudocode. c) How many comparisons does the algorithm use? A2: a) This algorithm first assigns the initial term of the sequence, a1, to the variable max. The “for” loop is used to successively examine terms of the sequence. If a term is greater than the current value of max, it is assigned to be the new value of max. b) procedure max(a1, a2, . . . , an: integers) max := a1 for i := 2 to n if max < ai then max := ai return max{max is the largest element}

786

c) Solution: The number of comparisons will be used as the measure of the time complexity of the algorithm, because comparisons are the basic operations used. To find the maximum element of a set with n elements, listed in an arbitrary order, the temporary maximum is first set equal to the initial term in the list. Then, after a comparison i ≤ n has been done to determine that the end of the list has not yet been reached, the temporary maximum and second term are compared, updating the temporary maximum to the value of the second term if it is larger. This procedure is continued, using two additional comparisons for each term of the list—one i ≤ n, to determine that the end of the list has not been reached and another max < ai , to determine whether to update the temporary maximum. Because two comparisons are used for each of the second through the nth elements and one more comparison is used to exit the loop when i = n + 1, exactly 2(n − 1) + 1 = 2n − 1 comparisons are used whenever this algorithm is applied. Hence, the algorithm for finding the maximum of a set of n elements has time complexity _(n), measured in terms of the number of comparisons used. Note that for this algorithm the number of comparisons is independent of particular input of n numbers. Next, we will analyze the time complexity of searching algorithms 3. a) State the definition of the fact that f (n) is O(g(n)), where f (n) and g(n) are functions from the set of positive integers to the set of real numbers. b) Use the definition of the fact that f (n) is O (g (n)) directly to prove or disprove that n2 + 18n + 107 is O (n3). c) Use the definition of the fact n is O (g (n)) directly to prove or disprove that n3 is O (n2 + 18n + 107). A3: a) Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers.We say that f (x) is O(g(x)) if there are constants C and k such that |f (x)| ≤ C|g(x)| whenever x > k. [This is read as “f (x) is big-oh of g(x).”] b) n2 +l8n+107:::; n3 + n3 + n3 = 3n3 for all n > 107. c) n3 is not less than a constant times n2 + 18n + 107, since their ratio exceeds n3 / (3n2) = n/3 for all n > 107. Q4. List these functions so that each function is big-O of the next function in the list: (log n)3, n3/1000000, √n,100n + 101, 3n, n!, 2nn2.

A4: (log n)3 , √n, l00n + 101, n3 /1000000, 2n n2 , 3n, n! Q5. a) How can you produce a big-O estimate for a function that is the sum of different terms where each term is the product of several functions? b) Give a big-O estimate for the function f (n) = (n! + 1)(2n + 1) + (nn−2 + 8nn−3) (n3 + 2n). For the function g in your estimate f (x) is O(g(x)) use a simple function of smallest possible order. A5: a) For the sum, take the largest term; for the product multiply the factors together. b) g(n) = nn-2 2n = (2n)n /n2 Q6. a) Define what the worst-case time complexity, average case time complexity, and best-case time complexity (in terms of comparisons) mean for an algorithm that finds the smallest integer in a list of n integers. b) What are the worst-case, average-case, and best-case time complexities, in terms of comparisons, of the algorithm that finds the smallest integer in a list of n integers by comparing each of the integers with the smallest integer found so far? A6: a) the largest, average, and smallest number of comparisons used by the algorithm before it stops, among all lists of n integers b) all are n - 1 Q7. a) Describe the linear search and binary search algorithm for finding an integer in a list of integers in increasing order. b) Compare the worst-case time complexities of these two algorithms.

786

c) Is one of these algorithms always faster than the other (measured in terms of comparisons)? A7: a) The linear search: The first algorithm that we will present is called the linear search, or sequential search, algorithm. The linear search algorithm begins by comparing x and a1. When x = a1, the solution is the location of a1, namely, 1. When x _= a1, compare x with a2. If x = a2, the solution is the location of a2, namely, 2. When x _= a2, compare x with a3. Continue this process, comparing x successively with each term of the list until a match is found, where the solution is the location of that term, unless no match occurs. If the entire list has been searched without locating x, the solution is 0. The pseudocode for the linear search algorithm is displayed as Algorithm 2. The linear search algorithm. procedure linear search(x: integer, a1, a2, . . . , an: distinct integers) i := 1 while (i ≤ n and x _= ai ) i := i + 1 if i ≤ n then location := i else location := 0 return location{location is the subscript of the term that equals x, or is 0 if x is not found} The binary search: We will now consider another searching algorithm. This algorithm can be used when the list has terms occurring in order of increasing size (for instance: if the terms are numbers, they are listed from smallest to largest; if they are words, they are listed in lexicographic, or alphabetic, order). This second searching algorithm is called the binary search algorithm. It proceeds by comparing the element to be located to the middle term of the list. The list is then split into two smaller sublists of the same size, or where one of these smaller lists has one fewer term than the other. The search continues by restricting the search to the appropriate sublist based on the comparison of the element to be located and the middle term. In Section 3.3, it will be shown that the binary search algorithm is much more efficient than the linear search algorithm. Example 3 demonstrates how a binary search works. E.g: To search for 19 in the list 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22, first split this list, which has 16 terms, into two smaller lists with eight terms each, namely, 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22. Then, compare 19 and the largest term in the first list. Because 10 < 19, the search for 19 can be restricted to the list containing the 9th through the 16th terms of the original list. Next, split this list, which has eight terms, into the two smaller lists of four terms each, namely, 12 13 15 16 18 19 20 22. Because 16 < 19 (comparing 19 with the largest term of the first list) the search is restricted to the second of these lists, which contains the 13th through the 16th terms of the original list. The list 18 19 20 22 is split into two lists, namely, 18 19 20 22. Because 19 is not greater than the largest term of the first of these two lists, which is also 19, the search is restricted to the first list: 18 19, which contains the 13th and 14th terms of the original list. Next, this list of two terms is split into two lists of one term each: 18 and 19. Because 18 < 19, the search is restricted to the second list: the list containing the 14th term of the list, which is 19. Now that the search has been narrowed down to one term, a comparison is made, and 19 is located as the 14th term in the original list. We now specify the steps of the binary search algorithm. To search for the integer x in the list a1,

a2, . . . , an, where a1 < a2 < ・ ・ ・ < an, begin by comparing x with the middle term am of the list, where m = _(n + 1)/2_. (Recall that _x_ is the greatest integer not exceeding x.) If x > am, the search for x is restricted to the second half of the list, which is am+1, am+2, . . . , an. If x is not greater than am, the search for x is restricted to the first half of the list, which is a1, a2,…am.The search has now been restricted to a list with no more than _n/2_ elements. (Recall that [x] is the smallest integer greater than or equal to x.) Using the same procedure, compare x to the

786

middle term of the restricted list. Then restrict the search to the first or second half of the list. Repeat this process until a list with one term is obtained. Then determine whether this term is x. Pseudocode for the binary search algorithm is displayed as Algorithm 3. The binary search algorithm: procedure binary search (x: integer, a1, a2, . . . , an: increasing integers) i := 1{i is left endpoint of search interval} j := n {j is right endpoint of search interval} while i < j m := _(i + j)/2_ if x > am then i := m + 1 else j := m if x = ai then location := i else location := 0 return location{location is the subscript i of the term ai equal to x, or 0 if x is not found} Algorithm 3 proceeds by successively narrowing down the part of the sequence being searched. At any given stage only the terms from ai to aj are under consideration. In other words, i and j are the smallest and largest subscripts of the remaining terms, respectively. Algorithm 3 continues narrowing the part of the sequence being searched until only one term of the sequence remains. When this is done, a comparison is made to see whether this term equals x. b) The type of complexity analysis done in Example 2 is a worstcase analysis. By the worst-case performance of an algorithm, we mean the largest number of operations needed to solve the given problem using this algorithm on input of specified size. Worst-case analysis tells us how many operations an algorithm requires to guarantee that it will produce a solution. c) No-it depends on the lists involved. (However, the worst case complexity for binary search is always better than that for linear search for lists of any given size except for very short lists.) Q8. a) Describe the bubble sort algorithm. b) Use the bubble sort algorithm to sort the list 5, 2, 4, 1, 3. c) Give a big-O estimate for the number of comparisons used by the bubble sort. A8: a) Bubble Sort: The bubble sort is one of the simplest sorting algorithms, but not one of the most efficient. It puts a list into increasing order by successively comparing adjacent elements, interchanging them if they are in the wrong order. To carry out the bubble sort, we perform the basic operation, that is, interchanging a larger element with a smaller one following it, starting at the beginning of the list, for a full pass.We iterate this procedure until the sort is complete. Pseudocode for the bubble sort is given as Algorithm 4.We can imagine the elements in the list placed in a column. In the bubble sort, the smaller elements “bubble” to the top as they are interchanged with larger elements. The larger elements “sink” to the bottom. This is illustrated in Example 4. E.g: Use the bubble sort to put 3, 2, 4, 1, 5 into increasing order.

Note: Blue Color is for an interchange Red Color for pair in correct order Green Color is numbers in color guaranteed to be in correct order. For more information See book

First Pass Second

Pass

Third

Pass

Forth

Pass

3 2 2 2 2 2 2 2 1 1

2 3 3 3 3 3 1 1 2 2

4 4 4 1 1 1 3 3 3 3

1 1 1 4 4 4 4 4 4 4

5 5 5 5 5 5 5 5 5 5

786

page no (197) b) On the first pass, the 5 bubbles down to the end, producing 2 4 1 3 5. On the next pass, the 4 bubbles down to the end, producing 213 4 5. On the next pass, the 1 and the 2 are swapped. No further changes are made on the fourth pass. c) The bubble sort described before Example 4 in Section 3.1 sorts a list by performing a sequence of passes through the list. During each pass the bubble sort successively compares adjacent elements, interchanging them if necessary. When the ith pass begins, the i − 1 largest elements are guaranteed to be in the correct positions. During this pass, n − i comparisons are used. Consequently, the total number of comparisons used by the bubble sort to order a list of n elements is

(n − 1) + (n − 2) +・ ・ ・+2 + 1 = (n − 1)n/2 Note that the bubble sort always uses this many comparisons, because it continues even if the list becomes completely sorted at some intermediate step. Consequently, the bubble sort uses (n − 1)n/2 comparisons, so it has O(n2) worst-case complexity in terms of the number of comparisons used. Q9. a) Describe the insertion sort algorithm. b) Use the insertion sort algorithm to sort the list 2, 5, 1, 4, 3. c) Give a big-O estimate for the number of comparisons used by the insertion sort. A9: a) The insertion sort is a simple sorting algorithm, but it is usually not the most efficient. To sort a list with n elements, the insertion sort begins with the second element. The insertion sort compares this second element with the first element and inserts it before the first element if it does not exceed the first element and after the first element if it exceeds the first element. At this point, the first two elements are in the correct order. The third element is then compared with the first element, and if it is larger than the first element, it is compared with the second element; it is inserted into the correct position among the first three elements. In general, in the j th step of the insertion sort, the j th element of the list is inserted into the correct position in the list of the previously sorted j − 1 elements. To insert the j th element in the list, a linear search technique is used (see Exercise 43); the j th element is successively compared with the already sorted j − 1 elements at the start of the list until the first element that is not less than this element is found or until it has been compared with all j − 1 elements; the j th element is inserted in the correct position so that the first j elements are sorted. The algorithm continues until the last element is placed in the correct position relative to the already sorted list of the first n − 1 elements. The insertion sort is described in pseudocode in Algorithm 5. E.g: Use the insertion sort to put the elements of the list 3, 2, 4, 1, 5 in increasing order. Solution: The insertion sort first compares 2 and 3. Because 3 > 2, it places 2 in the first position, producing the list 2, 3, 4, 1, 5 (the sorted part of the list is shown in color). At this point, 2 and 3 are in the correct order. Next, it inserts the third element, 4, into the already sorted part of the list by making the comparisons 4 > 2 and 4 > 3. Because 4 > 3, 4 remains in the third position. At this point, the list is 2, 3, 4, 1, 5 and we know that the ordering of the first three elements is correct. Next, we find the correct place for the fourth element, 1, among the already sorted elements, 2, 3, 4. Because 1 < 2, we obtain the list 1, 2, 3, 4, 5. Finally, we insert 5 into the correct position by successively comparing it to 1, 2, 3, and 4. Because 5 > 4, it stays at the end of the list, producing the correct order for the entire list. Insertion Sort algorithm: procedure insertion sort(a1, a2, . . . , an: real numbers with n ≥ 2) for j := 2 to n i := 1 while aj > ai i := i + 1 m := aj

786

for k := 0 to j − i − 1 aj−k := aj−k−1 ai := m {a1, . . . , an is in increasing order} b) On the first pass, the 5 is inserted into its correct position relative to the 2, producing 2 5 14 3. On the next pass, the 1 is inserted into its correct position relative to 2 5, producing 1 2 5 4 3. On the next pass, the 4 is inserted into its correct position relative to 1 2 5, producing 1 2 4 5 3. On the final pass, the 3 is inserted, producing the sorted list. c) O(n2 ); E.g: What is the worst-case complexity of the insertion sort in terms of the number of comparisons made? Solution: The insertion sort (described in Section 3.1) inserts the j th element into the correct position among the first j − 1 elements that have already been put into the correct order. It does this by using a linear search technique, successively comparing the j th element with successive terms until a term that is greater than or equal to it is found or it compares aj with itself and stops because aj is not less than itself. Consequently, in the worst case, j comparisons are required to insert the j th element into the correct position. Therefore, the total number of comparisons used by the insertion sort to sort a list of n elements is

2 + 3+・ ・ ・+n = n(n + 1)/2 – 1 using the summation formula for the sum of consecutive integers in line 2 of Table 2 of Section 2.4 (and see Exercise 37(b) of Section 2.4), and noting that the first term, 1, is missing in this sum. Note that the insertion sort may use considerably fewer comparisons if the smaller elements started out at the end of the list. We conclude that the insertion sort has worst-case complexity O(n2). Q10. a) Explain the concept of a greedy algorithm. b) Provide an example of a greedy algorithm that produces an optimal solution and explain why it produces an optimal solution. c) Provide an example of a greedy algorithm that does not always produce an optimal solution and explain why it fails to do so. A10: a) Algorithms that make what seems to be the “best”choice at each step are called greedy algorithms. Once we know that a greedy algorithm finds a feasible solution, we need to determine whether it has found an optimal solution. (Note that we call the algorithm “greedy” whether or not it finds an optimal solution.) To do this, we either prove that the solution is optimal or we show that there is a counterexample where the algorithm yields a non optimal solution. ....See page NO (198) for extra details in Book b) Consider the problem of making n cents change with quarters, dimes, nickels, and pennies, and using the least total number of coins.We can devise a greedy algorithm for making change for n cents by making a locally optimal choice at each step; that is, at each step we choose the coin of the largest denomination possible to add to the pile of change without exceeding n cents. For example, to make change for 67 cents, we first select a quarter (leaving 42 cents).We next select a second quarter (leaving 17 cents), followed by a dime (leaving 7 cents), followed by a nickel (leaving 2 cents), followed by a penny (leaving 1 cent), followed by a penny. We display a greedy change-making algorithm for n cents, using any set of denominations of coins, as Algorithm 6. Algorithm of Greedy Algorithm: procedure change(c1, c2, . . . , cr : values of denominations of coins, where

c1 > c2 > ・ ・ ・ > cr ; n: a positive integer)

786

for i := 1 to r di := 0 {di counts the coins of denomination ci used} while n ≥ ci di := di + 1 {add a coin of denomination ci} n := n − ci {di is the number of coins of denomination ci in the change for i = 1, 2, . . . , r} We have described a greedy algorithm for making change using any finite set of coins with denominations c1, c2, ..., cr . In the particular case where the four denominations are quarters dimes, nickels, and pennies, we have c1 = 25, c2 = 10, c3 = 5, and c4 = 1. For this case, we will show that this algorithm leads to an optimal solution in the sense that it uses the fewest coins possible. Before we embark on our proof, we show that there are sets of coins for which the greedy algorithm (Algorithm 6) does not necessarily produce change using the fewest coins possible. For example, if we have only quarters, dimes, and pennies (and no nickels) to use, the greedy algorithm would make change for 30 cents using six coins—a quarter and five pennies—whereas we could have used three coins, namely, three dimes. c) Use the greedy algorithm to make change using quarters, dimes, and pennies (but no nickels) for each of the amounts given in Exercise 53. For which of these amounts does the greedy algorithm use the fewest coins of these denominations possible? Solution: Two quarters, one dime, nine pennies. In page (S-20) question No(55) Q11. Define what it means for a problem to be tractable and what it means for a problem to be solvable. A11: A problem that is solvable using an algorithm with polynomial worst-case complexity is called tractable, because the expectation is that the algorithm will produce the solution to the problem for reasonably sized input in a relatively short time. However, if the polynomial in the big-_ estimate has high degree (such as degree 100) or if the coefficients are extremely large, the algorithm may take an extremely long time to solve the problem. Consequently, that a problem can be solved using an algorithm with polynomial worst-case time complexity is no guarantee that the problem can be solved in a reasonable amount of time for even relatively small input values. Fortunately, in practice, the degree and coefficients of polynomials in such estimates are often small. The situation is much worse for problems that cannot be solved using an algorithm with worst-case polynomial time complexity. Such problems are called intractable. Usually, but not always, an extremely large amount of time is required to solve the problem for the worst cases of even small input values. In practice, however, there are situations where an algorithm with a certain worst-case time complexity may be able to solve a problem much more quickly for most cases than for its worst case. When we are willing to allow that some, perhaps small, number of cases may not be solved in a reasonable amount of time, the average-case time complexity is a better measure of how long an algorithm takes to solve a problem. Many problems important in industry are thought to be intractable but can be practically solved for essentially all sets of input that arise in daily life. Another way that intractable problems are handled when they arise in practical applications is that instead of looking for exact solutions of a problem, approximate solutions are sought. It may be the case that fast algorithms exist for finding such approximate solutions, perhaps even with a guarantee that they do not differ by very much from an exact solution. Some problems even exist for which it can be shown that no algorithm exists for solving them. Such problems are called unsolvable (as opposed to solvable problems that can be solved using an algorithm). The first proof that there are unsolvable problems was provided by the great English mathematician and computer scientist Alan Turing when he showed that the halting problem is unsolvable. Recall that we proved that the halting problem is unsolvable in Section 3.1 A solvable problem is simply one that can be solved by an algorithm. The halting problem is proved on pp. 201-202 to be unsolvable. Page : 307

786

Q1.Find 210 div 17 and 210 mod 17.

A1: Dividing 210 by 17 gives a quotient of 12 and a remainder of 6, which are the respective

requested values.

210 ÷ 17 = 𝟏𝟐 ∗ 17 + 6 210%17 = 6

Q2. a) Define what it means for a and b to be congruent modulo 7.

a) 7 | a - b

b) Which pairs of the integers −11,−8,−7,−1, 0, 3, and 17 are congruent modulo 7?

b) 0 ≡ -7; -1 ≡ -8; 3 ≡ 17 ≡ -11

c) Show that if a and b are congruent modulo 7, then 10a + 13 and−4b + 20 are also congruent modulo 7. c) (10a + 13) - (-4b + 20) = 3(a - b) + 7(a + b - 1); note that 7 divides both terms

Q3. Show that if a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m). A3: THEOREM 5

Let m be a positive integer. If a ≡ b(mod m) and c ≡ d(mod m), then a + c ≡ b + d(mod m) and

ac ≡ bd (mod m).

Proof:

We use a direct proof. Because a ≡ b(mod m) and c ≡ d(mod m), by Theorem 4 t

are integers s and t with b = a + sm and d = c + tm. Hence,

b + d = (a + sm) + (c + tm) = (a + c) + m(s + t)

and

bd = (a + sm)(c + tm) = ac + m(at + cs + stm).

Hence,

a + c ≡ b + d(mod m) and ac ≡ bd (mod m).

E.g 6 Because 7 ≡ 2 (mod 5) and 11 ≡ 1 (mod 5), it follows from Theorem 5 that

18 = 7 + 11 ≡ 2 + 1 = 3 (mod 5), and that

77 7 · 11 ≡ 2 · 1 = 2 (mod 5).

Q4.Describe a procedure for converting decimal (base 10) expansions of integers into

hexadecimal expansions.

A4:

E.g 5: Find the hexadecimal expansion of (177130)10.

Solution: First divide 177130 by 16 to obtain

177130 = 16 · 11070 + 10.

Successively dividing quotients by 16 gives

11070 = 16 · 691 + 14,

691 = 16 · 43 + 3,

43 = 16 · 2 + 11,

2 = 16 · 0 + 2.

The successive remainders that we have found, 10, 14, 3, 11, 2, give us the digits from the

right to the left of 177130 in the hexadecimal (base 16) expansion of (177130)10. It follows

that

(177130)10 = (2B3EA)16.

(Recall that the integers 10, 11, and 14 correspond to the hexadecimal digits A, B, and E,

respectively.)

786

Q5. Convert (1101 1001 0101 1011)2 to octal and hexadecimal representations.

A5: Octal: 154533;

hexadecimal: D95B

Q6. Convert (7206)8 and (A0EB)16 to a binary representation.

A6: (7206)8 =1110 1000 0110

(A0EB)16 =1010 0000 1110 1011;

Q7. State the fundamental theorem of arithmetic. A7: THEOREM 1 The fundamental theorem of arithmetic: Every integer greater than 1 can be written uniquely as a prime or as the product of two or more primes where the prime factors are written in order of no decreasing size. E.g: gives some prime factorizations of integers. E.g 2: The prime factorizations of 100, 641, 999, and 1024 are given by 100 = 2 · 2 · 5 · 5 = 2252, 641 = 641,

999 = 3 · 3 · 3 · 37 = 33 · 37,

1024 = 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 = 210.

Q8. a) Describe a procedure for finding the prime factorization of an integer.

A8:

Find the prime factorization of 7007.

Solution:

To find the prime factorization of 7007, first perform divisions of 7007 by successive primes,

beginning with 2. None of the primes 2, 3, and 5 divides 7007. However, 7 divides 7007, with 7007/7

= 1001. Next, divide 1001 by successive primes, beginning with 7.It is immediately seen that 7 also

divides 1001, because 1001/7 = 143. Continue by dividing 143 by successive primes, beginning with

7. Although 7 does not divide 143, 11 does divide 143, and 143/11 = 13. Because 13 is prime, the

procedure is completed. It follows that 7007 = 7 · 1001 = 7 · 7 · 143 = 7 · 7 · 11· 13. Consequently, the

prime factorization of 7007 is 7 · 7 · 11 · 13 = 72 · 11 · 13. ▲

b) Use this procedure to find the prime factorization of 80,707.

b) 112 . 23 . 29

Q9. a) Define the greatest common divisor of two integers.

A9: Let a and b be integers, not both zero. The largest integer d such that d | a and d | b is called the

greatest common divisor of a and b. The greatest common divisor of a and b is denoted by gcd(a, b).

E.g: What is the greatest common divisor of 24 and 36?

Solution: The positive common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. Hence, gcd(24, 36) = 12.

See the Note Also

a) Describe at least three different ways to find the greatest common divisor of two integers

.When does each method work best?

b) find all the common factors (not a good algorithm unless the numbers are really

small); find the prime

factorization of each integer (works well if the numbers aren't too big and therefore can be

easily factored); use the Euclidean algorithm (really the best method). See the Algorithm in Book

P()

a) Find the greatest common divisor of 1,234,567 and 7,654,321.

786

1,234,567 and 7,654,321 =1 (use the Euclidean algorithm)

a) Find the greatest common divisor of 2335577911 and 2937557313.

d) 23355573

Q10. a) How can you find a linear combination (with integer coefficients) of two integers that

equals their greatest common divisor?

a) Use the Euclidean algorithm; see Example 17 in Section 4.3. EXAMPLE 17 Express gcd(252, 198) = 18 as a linear combination of 252 and 198. Solution: To show that gcd(252, 198) = 18, the Euclidean algorithm uses these divisions: 252 = 1 · 198 + 54 198 = 3 · 54 + 36 54 = 1 · 36 + 18 36 = 2 · 18. Using the next-to-last division (the third division), we can express gcd(252, 198) = 18 as a linear combination of 54 and 36.We find that 18 = 54 − 1 · 36. The second division tells us that 36 = 198 − 3 · 54. Substituting this expression for 36 into the previous equation, we can express 18 as a linear combination of 54 and 198.We have 18 = 54 − 1 · 36 = 54 − 1 · (198 − 3 · 54) = 4 · 54 − 1 · 198. The first division tells us that 54 = 252 − 1 · 198. Substituting this expression for 54 into the previous equation, we can express 18 as a linear combination of 252 and 198.We conclude that 18 = 4 · (252 − 1 · 198) − 1 · 198 = 4 · 252 − 5 · 198, completing the solution. b) Express gcd(84, 119) as a linear combination of 84 and 119.

b) 7 = 5 . 119 - 7. 84

Q11. a) What does it mean for( ‘a) to be an inverse of a modulo m?

a) aa’ = 1 (mod m)

b) How can you find an inverse of a modulo m when m is a positive integer and gcd(a,m) = 1?

b) Express 1 as sa + tm (see Review Question 10). Then s is the inverse of a modulo m.

c) Find an inverse of 7 modulo 19.

c) 11;

Q12. a) How can an inverse of a modulo m be used to solve the congruence ax ≡ b(mod m) when

gcd (a ,m) = 1?

a) Multiply each side by the inverse of a modulo m.

b) Solve the linear congruence 7x ≡ 13 (mod 19).

b) { 10 + 19k I k E z }

Q13. a) State the Chinese remainder theorem. A13: THE CHINESE REMAINDER THEOREM Let m1,m2,...,mn be pairwise relatively prime positive integers greater than one and a1,a2,...,an arbitrary integers. Then the system x ≡ a1 (mod m1),

786

x ≡ a2 (mod m2), · · · x ≡ an (mod mn) has a unique solution modulo m = m1m2 ···mn. (That is, there is a solution x with 0 ≤ x<m, and all other solutions are congruent modulo m to this solution.) x = a M y + a M y +···+ a M y . x ≡ akMkyk ≡ ak (mod mk), for k = 1, 2,...,n.We have shown that x is a simultaneous solution to the n congruences. EXAMPLE 5 To solve the system of congruences in Example 4, first let m = 3 · 5 · 7 = 105, M1 = m/3 = 35,M2 = m/5 = 21, and M3 = m/7 = 15.We see that 2 is an inverse of M1 = 35 modulo 3, because 35 · 2 ≡ 2 · 2 ≡ 1 (mod 3); 1 is an inverse of M2 = 21 modulo 5, because 21 ≡ 1 (mod 5); and 1 is an inverse of M3 = 15 (mod 7), because 15 ≡ 1 (mod 7). The solutions to this system are those x such that x ≡ a1M1y1 + a2M2y2 + a3M3y3 = 2 · 35 · 2 + 3 · 21 · 1 + 2 · 15 · 1 = 233 ≡ 23 (mod 105). b) Find the solutions to the system x ≡ 1 (mod 4), x ≡ 2 (mod 5), and x ≡ 3 (mod 7). b) { 17 + l40k I k E z} Q14. Suppose that 2n−1 ≡ 1 (mod n).Is n necessarily prime? No; n could be a pseudo prime such as 341.

15. Use Fermat’s little theorem to evaluate 9200 mod 19. 9200 = 918 . 92 . 9180 = 918 . 92 . (918)20 = 1 . 81 . 120 = 81 = 5 (mod 19) 16. Explain how the check digit is found for a 10-digit ISBN.

Example 6 : ISBNs All books are identified by an International Standard Book Number (ISBN-10),a 10-digit code x1x2 ...x10, assigned by the publisher. (Recently, a 13-digit code known as ISBN- 13 was introduced to identify a larger number of published works; see the preamble to Exercise 42 in the Supplementary Exercises.) An ISBN-10 consists of blocks identifying the language, the publisher, the number assigned to the book by its publishing company, and finally, a check digit that is either a digit or the letter X (used to represent 10). This check digit is selected so that

𝑥10 ≡ ∑ 𝑖𝑥𝑖(mod 11)

9

𝑖=1

or equivalently, so that

∑ 𝑖𝑥𝑖 ≡ 0(mod 11)

10

𝑖=1

Answer these questions about ISBN-10s: (a) The first nine digits of the ISBN-10 of the sixth edition of this book are 007288008.What is the check digit? (b) Is 084930149X a valid ISBN-10? Solution: (a) The check digit is determined by the congruence 10 i=1 ixi ≡ 0 (mod 11). Inserting the digits 007288008 gives x10 ≡ 1 · 0 + 2 · 0 + 3 · 7 + 4 · 2 + 5 · 8 + 6 · 8 + 7 · 0 + 8 · 0 +

786

9 · 8 (mod 11). This means that x10 ≡ 0 + 0 + 21 + 8 + 40 + 48 + 0 + 0 + 72 (mod 11), so x10 ≡ 189 ≡ 2 (mod 11). Hence, x10 = 2. (b) To see whether 084930149X is a valid ISBN-10, we see if 10 i=1 ixi ≡ 0 (mod 11). We see that 1 · 0 + 2 · 8 + 3 · 4 + 4 · 9 + 5 · 3 + 6 · 0 + 7 · 1 + 8 · 4 + 9 · 9 + 10 · 10 = 0 + 16 + 12 + 36 + 15 + 0 + 7 + 32 + 81 + 100 = 299 ≡ 2 ≡ 0 (mod 11). Hence, 084930149X is not a valid ISBN-10. Q17. Encrypt the message APPLES AND ORANGES using a shift cipher with key k = 13.

A17: NCCYRF NAQ BENATRF

Q18. a) What is the difference between a public key and a private key cryptosystem? سم کتل غواړي b) Explain why using shift ciphers is a private key system. b) The amount of shift, k, is kept secret. It is needed both to encode and to decode messages. c) Explain why the RSA cryptosystem is a public key system. c) Although the key for decoding, d, is kept secret, the keys for encoding, n and e, are published. 19. Explain how encryption and decryption are done in the RSA cryptosystem. 299-301 صفحه کتل 20. Describe how two parties can share a secret key using the Diffie-Hellman key exchange

protocol.

صفحه کتل 302

Page : 378

Q1. a) Can you use the principle of mathematical induction to find a formula for the sum of the first n terms of a sequence? a) no b) Can you use the principle of mathematical induction to determine whether a given formula for the sum of the first n terms of a sequence is correct? b) Sometimes yes. If the given formula is correct, then it is often possible to prove it using the principle of mathematical induction (although it would be wishful thinking to believe that every such true formula could be so proved). If the formula is incorrect, then induction would not work, of course; thus an incorrect formula could not be shown to be incorrect using the principle. c) Find a formula for the sum of the first n even positive integers, and prove it using mathematical induction. Exercise 9.

C) Find a formula for the sum of the first n even positive integers. a) 2+4+6+···+2n = n(n+1)

b) Prove the formula that you conjectured in part (a). b) Basis step: 2 = 1·(1+1) is true. Inductive step: Assume that 2 + 4 + 6 +···+ 2k = k(k + 1). Then (2 + 4 + 6 + ··· + 2k) + 2(k + 1) = k(k+1)+2(k+1) = (k+1)(k+2).

Q2. a) For which positive integer’s n are 11n + 17 ≤ 2n?

786

a) n ≥ 7 b) Prove the conjecture you made in part (a) using mathematical induction. b) For the basis step we just check that 11 · 7 + 17 ≤ 27. Fix n ≥ 7, and assume the inductive hypothesis, that 11n + 17 ≤ 2n. Then 11(n + 1) + 17= (11n+17) + 11≤2n+11 < 2n + 2n = 2n+1. The strict inequality here follows from the fact that n ≥ 4. Q3. a) Which amounts of postage can be formed using only 5-cent and 9-cent stamps? a) Carefully considering all the possibilities shows that the amounts of postage less than 32 cents that can be achieved are 0, 5, 9, 10, 14, 15, 18, 19, 20, 23, 24, 25, 27, 28, 29, and 30. All amounts greater than or equal to 32 cents can be achieved. b) Prove the conjecture you made using mathematical induction. b) To prove this latter statement, we check the basis step by noting that 32 = 9 + 9 + 9 + 5. Assume that we can achieve n cents, and consider n + 1 cents, where n ≥ 32. If the stamps used for n cents included a 9-cent stamp, then replacing it by two 5-cent stamps gives us n + 1 cents, as desired. Otherwise only 5-cent stamps were used to achieve n cents, and since n > 30, there must be at least seven such stamps. Replace seven of the 5-cent stamps by four 9-cent stamps; this increases the amount of postage by 4 · 9 - 7 · 5 = 1 cent, again as desired. c) Prove the conjecture you made using strong induction. c) We check the base cases 32 = 3 · 9 + 5, 33 = 2 · 9 + 3 · 5, 34 = 9 + 5 · 5, 35 = 7 · 5, and 36 = 4 · 9. Fix n ≥ 37 and assume that all amounts from 32 to n - 1 can be achieved. To achieve n cents postage, take the stamps used for n - 5 cents (since n ≥ 37, n - 5 ≥ 32, so the inductive hypothesis applies) and adjoin a 5-cent stamp. d) Find a proof of your conjecture different from the ones you gave in (b) and (c). d) Let n be an integer greater than or equal to 32. We want to express n as a sum of a nonnegative multiple of 5 and a nonnegative multiple of 9. Divide n by 5 to obtain a quotient q and remainder r such that n = 5q + r and 0 ≤ r ≤ 4. Note that since n ≥32, q ≥ 6. If r = 0, then we already have n expressed in the desired form. If r = 1, then n ≥ 36, so q ≥ 7; thus we can write n = 5q + 1 = 5(q - 7) + 4 · 9 to get the desired decomposition. If r = 2, then we rewrite n = 5q + 2 = 5(q - 5) + 3 · 9. If r = 3, then we rewrite n = 5q + 3 = 5(q - 3) + 2 · 9. And if r = 4, then we rewrite n = 5q + 4 = 5(q - 1) + 9. In each case we have the desired sum. Q4. Give two different examples of proofs that use strong induction. Section 5.2 example 2 and 3 page 336; EXAMPLE 2 Show that if n is an integer greater than 1, then n can be written as the product of primes. Solution: Let P(n) be the proposition that n can be written as the product of primes. BASIS STEP: P(2) is true, because 2 can be written as the product of one prime, itself. (Note that P(2) is the first case we need to establish.) EXAMPLE 3 Consider a game in which two players take turns removing any positive number of matches they want from one of two piles of matches. The player who removes the last match wins the game. Show that if the two piles contain the same number of matches initially, the second player can always guarantee a win. Solution: Let n be the number of matches in each pile. We will use strong induction to prove P(n), the statement that the second player can win when there are initially n matches in each pile. Q5. a) State the well-ordering property for the set of positive integers. a) Seep. 314 and Appendix 1 (Axiom 4 for the positive integers). Axiom 4 The Well-Ordering Property Every nonempty subset of the set of positive integers has a least element. In Sections 5.1 and 5.2 it is shown that the well-ordering principle is equivalent to the principle of mathematical induction.

786

PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function, we complete two steps: BASIS STEP: We verify that P(1) is true. INDUCTIVE STEP: We show that the conditional statement P(k) → P(k + 1) is true for all positive integers k.

a) Use this property to show that every positive integer greater than one can be written as the product of primes.

b) Let S be the set of positive integers that cannot be written as the product of primes. If S #- 0, then S has a least element, c. Clearly c ≠ 1, since 1 is the product of no primes. Thus c is greater than 1. Now c cannot be prime, since as such it would already be written as the product of primes (namely itself). Therefore c is a composite number, say c =ab, where a and b are both positive integers less than c. Since c is the smallest element of S, neither a nor b is in S. Therefore both a and b can be written as the product of primes. But multiplying these products together patently shows that c is the product of primes. This is a contradiction to the choice of c. Therefore our assumption that S ≠ 0 was wrong, and the theorem is proved.

Q6. a) Explain why a function 𝒇 from the set of positive integers to the set of real numbers is well-defined if it is defined recursively by specifying 𝒇 (1) and a rule for finding 𝒇 (n) from 𝒇 (n − 1). a) See Exercise 56 in Section 5.3. 56. Use mathematical induction to prove that a function F defined by specifying F(0) and a rule for obtaining F(n + 1) from F(n) is well defined.

حل غواړي کتاب کي نسته b) Provide a recursive definition of the function 𝒇 (n) = (n + 1)! b) f(1) = 2, and f(n) = (n + l)f(n - 1) for all n ≥ 2

Q7. a) Give a recursive definition of the Fibonacci numbers. a) See the top of p. 347. Recall from Section 2.4 that the Fibonacci numbers, f0,f1,f2,..., are defined by the equations f0 = 0,f1 = 1, and fn = fn−1 + fn−2 for n = 2, 3, 4,.... [We can think of the Fibonacci number fn either as the nth term of the sequence of Fibonacci numbers f0,f1,... or as the value at the integer n of a function f (n).] We can use the recursive definition of the Fibonacci numbers to prove many properties of these numbers.We give one such property in Example 4. EXAMPLE 4 Show that whenever n ≥ 3, fn >αn−2, where α = (1 +√5)/2. Solution: We can use strong induction to prove this inequality. Let P(n) be the statement fn >αn−2.We want to show that P(n) is true whenever n is an integer greater than or equal to 3. BASIS STEP: First, note that α< 2 = f3, α2 = (3 +√5)/2 < 3 = f4, so P(3) and P(4) are true.

b) Show that 𝒇(𝒏) > 𝒂𝒏−𝟐whenever n ≥ 3, where 𝒇 n is the nth term of the Fibonacci sequence and

α =(1 +√5)/2. EXAMPLE 4 Show that whenever n ≥ 3, fn >αn−2, where α = (1 +√5)/2. Solution: We can use strong induction to prove this inequality. Let P(n) be the statement fn >αn−2.We want to show that P(n) is true whenever n is an integer greater than or equal to 3. BASIS STEP: First, note that α< 2 = f3, α2 = (3 +√5)/2 < 3 = f4, so P(3) and P(4) are true. Q8. a) Explain why a sequence an is well defined if it is defined recursively by specifying a1 and a2 and a rule for finding an from a1,a2,...,an−1 for n = 3, 4, 5,.... a) See Exercise 57 in Section 5.3. 57. Use strong induction to prove that a function F defined by specifying F(0) and a rule for obtaining F(n + 1) from the values F(k) for k = 0, 1, 2,...,n is well defined.

786

57. Let P(n) be “F(n) is well-defined.” Then P(0) is true because F(0) is specified. Assume that P(k) is true for all k<n. Then F(n) is well-defined at n because F(n) is given in terms of F(0), F(1), . . . , F(n − 1).So P(n) is true for all integers n. b) Find the value of an if a1 = 1, a2 = 2, and an = an−1 + an−2 +···+ a1, for n = 3, 4, 5,.... b) an = 3 · 2n-3 for n ≥ 3 9. Give two examples of how well-formed formulae are defined recursively for different sets of elements and operators. EXAMPLE 8 Well-Formed Formulae in Propositional Logic We can define the set of well-formed formulae in propositional logic involving T, F, propositional variables, and operators from the set {¬,∧,∨,→,↔}. BASIS STEP: T, F, and s, where s is a propositional variable, are well-formed formulae. RECURSIVE STEP: If E and F are well-formed formulae, then (¬E), (E ∧ F), (E ∨ F), (E → F), and (E ↔ F) are well-formed formulae.For example, by the basis step we know that T, F, p, and q are well-formed formulae, where p and q are propositional variables. From an initial application of the recursive step, we know that (p ∨ q), (p → F), (F → q), and (q ∧ F) are well-formed formulae. A second application of the recursive step shows that ((p ∨ q) → (q ∧ F)), (q ∨ (p ∨ q)), and ((p → F) → T) are well-formed formulae. We leave it to the reader to show that p¬∧ q, pq∧, and ¬∧ pq are not well-formed formulae, by showing that none can be obtained using the basis step and one or more applications of the recursive step. ▲ EXAMPLE 9 Well-Formed Formulae of Operators and Operands We can define the set of well-formed formulae consisting of variables, numerals, and operators from the set {+,−, ∗, /, ↑} (where ∗ denotes multiplication and ↑ denotes exponentiation) recursively. BASIS STEP: x is a well-formed formula if x is a numeral or a variable. RECURSIVE STEP: If F and G are well-formed formulae, then (F + G), (F − G), (F ∗ G), (F/G), and (F ↑G) are well-formed formulae. For example, by the basis step we see that x, y, 0, and 3 are well-formed formulae (as is any variable or numeral).Well-formed formulae generated by applying the recursive step once include (x + 3), (3 + y), (x − y), (3 − 0), (x ∗ 3), (3 ∗ y), (3/0), (x/y), (3↑x), and (0↑3). Applying the recursive step twice shows that formulae such as ((x + 3) + 3) and (x − (3 ∗ y)) are well-formed formulae. [Note that (3/0) is a well-formed formula because we are concerned only with syntax matters here.]We leave it to the reader to show that each of the formulae x3+, y ∗+x, and ∗ x/y is not a well-formed formula by showing that none of them can be obtained from the basis step and one or more applications of the recursive step. ▲ Q10. a) Give a recursive definition of the length of a string. a) See Example 7 in Section 5.3. EXAMPLE 7 Length of a String Give a recursive definition of l(w), the length of the string w. Solution: The length of a string can be recursively defined by L(λ) = 0; L(wx) = L(w) + 1 if w ∈ ∑∗ and x ∈ ∑∗ . b) Use the recursive definition from part (a) and structural induction to prove that l(xy) = l(x) + l(y). EXAMPLE 12 Use structural induction to prove that l(xy) = l(x) + l(y), where x and y belong to ∗, the set of strings over the alphabet ∑ . Solution: We will base our proof on the recursive definition of the set ∑∗ given in Definition 1 and the definition of the length of a string in Example 7, which specifies that l(λ) = 0 and l(wx) = l(w) + 1 when w ∈ ∗ and x ∈ . Let P(y) be the statement that l(xy) = l(x) + l(y) whenever x belongs to ∑ ∗.

786

BASIS STEP: To complete the basis step, we must show that P(λ) is true. That is, we must show that l(xλ) = l(x) + l(λ) for all x ∈ ∗. Because l(xλ) = l(x) = l(x) + 0 = l(x) + l(λ) for every string x, it follows that P(λ) is true. Q11. a) What is a recursive algorithm? See the beginning of Section 5.4. DEFINITION 1 An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input. EXAMPLE 2 Give a recursive algorithm for computing an, where a is a nonzero real number and n is a nonnegative integer. Solution: We can base a recursive algorithm on the recursive definition of an. This definition states that an+1 = a · an for n> 0 and the initial condition a0 = 1. To find an, successively use the recursive step to reduce the exponent until it becomes zero. We give this procedure in Algorithm 2. ▲

b) Describe a recursive algorithm for computing the sum of n numbers in a sequence. b) Call the sequence a 1 , a2 , ... , an. If n = 1, then the sum(a1) = a1. Otherwise sum(a1,a2, ... ,an) =an + sum(a1,a2,…an-1 ).

Q12. Describe a recursive algorithm for computing the greatest common divisor of two positive integers. See Example 3 in Section 5.4. EXAMPLE 3 Give a recursive algorithm for computing the greatest common divisor of two nonnegative integers a and b with a<b. Solution: We can base a recursive algorithm on the reduction gcd(a, b) = gcd(b mod a,a) and the condition gcd(0,b) = b when b> 0. This produces the procedure inAlgorithm 3, which is a recursive version of the Euclidean algorithm. We illustrate the workings ofAlgorithm 3 with a trace when the input is a = 5, b = 8.With this input, the algorithm uses the “else” clause to find that gcd(5, 8) = gcd(8 mod 5, 5) = gcd(3, 5). It uses this clause again to find that gcd(3, 5) = gcd(5 mod 3, 3) = gcd(2, 3), then to get gcd(2, 3) = gcd(3 mod 2, 2) = gcd(1, 2), then to get gcd(1, 2) = gcd(2 mod 1, 1) = gcd(0, 1). Finally, to find gcd(0, 1) it uses the first step with a = 0 to find that gcd(0, 1) = 1.Consequently, the algorithm finds that gcd(5, 8) = 1. Q13. a) Describe the merge sort algorithm. The Merge Sort We now describe a recursive sorting algorithm called the merge sort algorithm. We will demonstrate how the merge sort algorithm works with an example before describing it in generality. In general, a merge sort proceeds by iteratively splitting lists into two sub lists of equal length (or where one sub list has one more element than the other) until each sub list contains one element. This succession of sub lists can be represented by a balanced binary tree. The procedure continues by successively merging pairs of lists, where both lists are in increasing order, into a larger list with elements in increasing order, until the original list is put into increasing order. The succession of merged lists can be represented by a balanced binary tree.

b) Use the merge sort algorithm to put the list 4, 10, 1, 5, 3, 8, 7, 2, 6, 9 in increasing order. b) We split the list into the two halves: 4, 10, 1, 5, 3 and 8, 7, 2, 6, 9. We then merge sort each half by applying this algorithm recursively and merging the results. For the first half, for example, this means splitting 4, 10, 1, 5, 3 into the two halves 4, 10, 1 and 5, 3, recursively sorting each half, and merging. For the second half of this, for example, it means splitting into 5 and 3, recursively sorting each half, and merging. Since these two halves are already sorted, we just merge, into the sorted list 3, 5. Similarly, we will get 1, 4, 10 for the result of merge sort applied to 4, 10, 1. When we merge 1, 4, 10 and 3, 5, we get 1, 3, 4, 5, 10. Finally, we merge this

786

with the sorted second half, 2, 6, 7, 8, 9, to obtain the completely sorted list 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. c) Give a big-O estimate for the number of comparisons used by the merge sort. LEMMA 1 Two sorted lists with m elements and n elements can be merged into a sorted list using no more than m + n − 1 comparisons.

THEOREM 1 The number of comparisons needed to merge sort a list with n elements is O(n log n). Q14. a) Does testing a computer program to see whether it produces the correct output for certain input values verify that the program always produces the correct output? a) no b) Does showing that a computer program is partially correct with respect to an initial assertion and a final assertion verify that the program always produces the correct output? If not, what else is needed? b) No-you also need to show that it halts for all inputs, and the initial and final assertions for which you provide a proof of partial correctness need to be appropriate ones (i.e., relevant to the question of whether the program produces the correct output). 15. What techniques can you use to show that a long computer program is partially correct with respect to an initial assertion and a final assertion? See the rules displayed in Section 5.5. Rules of Inference A useful rule of inference proves that a program is correct by splitting the program into a sequence of subprograms and then showing that each subprogram is correct. Suppose that the programS is split into subprograms S1 and S2.Write S = S1; S2 to indicate that S is made up of S1 followed by S2. Suppose that the correctness of S1 with respect to the initial assertion p and final assertion q, and the correctness of S2 with respect to the initial assertion q and the final assertion r, have been established. It follows that if p is true and S1 is executed and terminates, then q is true; and if q is true, and S2 executes and terminates, then r is true. Thus, if p is true and S = S1; S2 is executed and terminates, then r is true. This rule of inference, called the composition rule, can be stated as p{S1}q q{S2}r ∴ p{S1; S2}r. This rule of inference will be used later in this section. Next, some rules of inference for program segments involving conditional statements and loops will be given. Because programs can be split into segments for proofs of correctness, this will let us verify many different programs. Q16. What is a loop invariant? How is a loop invariant used? while condition S note that S is repeatedly executed until condition becomes false. An assertion that remains true each time S is executed must be chosen. Such an assertion is called a loop invariant. In other words, p is a loop invariant if (p ∧ condition){S}p is true. Example : i := 1 factorial := 1 while i<n i := i + 1 factorial := factorial · i

786

Page : 439 Q1. Explain how the sum and product rules can be used to find the number of bit strings with a length not exceeding 10. 1 + 2 + 2. 2 + 2. 2. 2 + ... + 210 = 2047 Q2. Explain how to find the number of bit strings of length not exceeding 10 that have at least one 0 bit. Subtract 11 from the answer to the previous review question, since >., 1, 11, ... , 11 ... 1 are the bit strings that do not have at least one 0 bit. Q3. a) How can the product rule be used to find the number of functions from a set with m elements to a set with n elements? a) See Example 6 in Section 6.1. example 6 : Counting Functions How many functions are there from a set with m elements to a set with n elements? Solution: A function corresponds to a choice of one of the n elements in the codomain for each of The m elements in the domain. Hence, by the product rule there are n · n · ··· · n = nm functions from a set with m elements to one with n elements. For example, there are 53 = 125 different functions from a set with three elements to a set with five elements. ▲

b) How many functions are there from a set with five elements to a set with 10 elements? b) 105

c) How can the product rule be used to find the number of one-to-one functions from a set with m elements to a set with n elements? c) See Example 7 in Section 6.1. example 7 : Counting One-to-One Functions How many one-to-one functions are there from a set with m elements to one with n elements? Solution: First note that when m>n there are no one-to-one functions from a set with m elements to a set with n elements. Now let m ≤ n. Suppose the elements in the domain are a1,a2,...,am. There are n ways to choose the value of the function at a1. Because the function is one-to-one, the value of the function at a2 can be picked in n − 1 ways (because the value used for a1 cannot be used again). In general, the value of the function at ak can be chosen in n − k + 1 ways. By the product rule, there are n(n − 1)(n − 2) ··· (n − m + 1) one-to-one functions from a set with m elements to one with n elements. For example, there are 5 · 4 · 3 = 60 one-to-one functions from a set with three elements to a set with five elements. ▲ d) How many one-to-one functions are there from a set with five elements to a set with 10 elements? d) 10·9·8·7·6 e)How many onto functions are there from a set with five elements to a set with 10 elements? e) 0 4. How can you find the number of possible outcomes of a playoff between two teams where the first team that wins four games wins the playoff? with a tree diagram; see Example 22 in Section 6.1 (extended to larger tree) EXAMPLE 22 A playoff between two teams consists of atmost five games. The first teamthat wins three games wins the playoff. In how many different ways can the playoff occur?

786

Solution: The tree diagram in Figure 3 displays all the ways the playoff can proceed, with the winner of each game shown. We see that there are 20 different ways for the playoff to occur. ▲ 5. How can you find the number of bit strings of length ten that either begin with 101 or end with 010? Using the inclusion-exclusion principle. we get 27 + 27 - 24; see Example 18 in Section 6.1. EXAMPLE 18 How many bit strings of length eight either start with a 1 bit or end with the two bits 00? Solution: We can construct a bit string of length eight that either starts with a 1 bit or ends with the two bits 00, by constructing a bit string of length eight beginning with a 1 bit or by constructing a bit string of length eight that ends with the two bits 00. We can construct a bit string of length eight that begins witha1in27 = 128 way the number of bit strings of length eight that begin witha1orend with a 00, which equals the number of ways to construct a bit string of length eight that begins witha1or that ends with 00, equals 128 + 64 − 32 = 160. 17 ليکچر درس دی Q6. a) State the pigeonhole principle. Introduction Suppose that a flock of 20 pigeons flies into a set of 19 pigeonholes to roost. Because there are 20 pigeons but only 19 pigeonholes, a least one of these 19 pigeonholes must have at least two pigeons in it. To see why this is true, note that if each pigeonhole had at most one pigeon in it, at most 19 pigeons, one per hole, could be accommodated. This illustrates a general principle called the pigeonhole principle, which states that if there are more pigeons than pigeonholes, then there must be at least one pigeonhole with at least two pigeons in it (see Figure 1). Of course, this principle applies to other objects besides pigeons and pigeonholes. THEOREM 1 THE PIGEONHOLE PRINCIPLE If k is a positive integer and k + 1 or more objects are placed into k boxes, then there is at least one box containing two or more of the objects. 17 lecture look

b) Explain how the pigeonhole principle can be used to show that among any 11 integers, at least two must have the same last digit. b) 11 pigeons, 10 holes (digits)

Q7. a) State the generalized pigeonhole principle. The pigeonhole principle states that there must be at least two objects in the same box when there are more objects than boxes. However, even more can be said when the number of objects exceeds a multiple of the number of boxes. For instance, among any set of 21 decimal digits there must be 3 that are the same. This follows because when 21 objects are distributed into 10 boxes, one box must have more than 2 objects.

786

b) Explain how the generalized pigeonhole principle can be used to show that among any 91 integers, there are at least ten that end with the same digit. b)N=91,k=10 Q8. a) What is the difference between an r-combination and an r-permutation of a set with n elements? a) Permutations are ordered arrangements; combinations are unordered (or just arbitrarily ordered for convenience) selections

b) Derive an equation that relates the number of r-combinations and the number of r-permutations of a set with n elements.

b) P(n,r) = C(n.r) · r! (see the proof of Theorem 2 in Section 6.3)

786

b) How many ways are there to select six students from a class of 25 to serve on a

committee? c) C(25, 6)

c) How many ways are there to select six students from a class of 25 to hold six different executive positions on a committee? d) P(25, 6)

Q9. a) What is Pascal’s triangle?

786

a) See pp. 418-419

419 صفحه کتل غواړي

This triangle is known as Pascal’s triangle. Pascal’s identity shows that when two adjacent binomial coefficients in this triangle are added, the binomial coefficient in the next row between these two coefficients is produced b) How can a row of Pascal’s triangle be produced from the one above it?

b) by adding the two numbers above each number in the new row Q10. What is meant by a combinatorial proof of an identity? How is such a proof different from an algebraic one?

A combinatorial proof is a proof of an algebraic identity that shows that both sides count the same thing (in some application). An algebraic proof is totally different-it shows that the two sides are equal by doing formal manipulations with the unknowns. with no reference to what the expressions might mean in an application. Q11. Explain how to prove Pascal’s identity using a combinatorial argument. See p. 418.

786

12. a) State the binomial theorem. a) See p. 416

786

b) Explain how to prove the binomial theorem using a combinatorial argument. b) See p. 416

c) Find the coefficient of x100y101 in the expansion of (2x + 5y)201. c) 2100.5101C (201, 101) Q13. a) Explain how to find a formula for the number of ways to select r objects from n objects when repetition is allowed and order does not matter. a) See Theorem 2 in Section 6.5

786

b) How many ways are there to select a dozen objects from among objects of five different types if objects of the same type are indistinguishable? b) C(5 + 12 - 1, 12) c) How many ways are there to select a dozen objects from these five different types if there must be at least three objects of the first type? c) C (5 + 9 - 1, 9) d) How many ways are there to select a dozen objects from these five different types if there cannot be more than four objects of the first type? d) C (5 + 12 -1.12) - C(5 + 7 - 1. 7) e) How many ways are there to select a dozen objects from these five different types if there must be at least two objects of the first type, but no more than three objects of the second type? e) C (5 + 10 - 1, 10) - C(5 + 6 - 1, 6) 14. a) Let n and r be positive integers. Explain why the number of solutions of the equation x1 + x2 +···+ xn = r, where xi is a nonnegative integer for i = 1, 2, 3,...,n, equals the number of r-combinations of a set with n elements. a) See Example 5 in Section 6.5.

b) How many solutions in nonnegative integers are there to the equation x1 + x2 + x3 + x4 = 17? b) C( 4 + 17 - 1, 17) c) How many solutions in positive integers are there to the equation in part (b)? c) C(4 + 13 - 1, 13) (see Exercise 15a in Section 6.5) 15. How many solutions are there to the equation x1 + x2 + x3 + x4 + x5 = 21, where xi , i = 1, 2, 3, 4, 5, is a nonnegative integer such that

786

a) x1 ≥ 1? b) xi ≥ 2 for i = 1, 2, 3, 4, 5? c) 0 ≤ x1 ≤ 10? d) 0 ≤ x1 ≤ 3, 1 ≤ x2 < 4, and x3 ≥ 15?

15. a) 10,626 b) 1,365 c) 11,649 d) 106

Q15. a) Derive a formula for the number of permutations of n objects of k different types, where there are n1 indistinguishable objects of type one, n2 indistinguishable objects of type two,..., and nk indistinguishable objects of type k. a) See Theorem 3 in Section 6.5.

b) How many ways are there to order the letters of the word INDISCREETNESS? b) 14!/(2!2!1!3!1!1!3!1!) Q16. Describe an algorithm for generating all the permutations of the set of the n smallest positive integers. 16. See pp. 435-436. کتل غواړې Q17. a) How many ways are there to deal hands of five cards to six players from a standard 52-card deck? a) C(52, 5) · C(47, 5) · C(42, 5) · C(37, 5) · C(32, 5) · C(27, 5) b) How many ways are there to distribute n distinguishable objects into k distinguishable boxes so that ni objects are placed in box i ? b) See Theorem 4 in Section 6.5

786

Q18. Describe an algorithm for generating all the combinations of the set of the n smallest positive integers. See pp. 437-438

EXAMPLE 4 Find the next bit string after 10 0010 0111. Solution: The first bit from the right that is nota1isthe fourth bit from the right. Change this bit to a 1 and change all the following bits to 0s. This produces the next larger bit string, 10 0010 1000 کتل غواړې

Page : 495 Q1. a) Define the probability of an event when all outcomes are equally likely. a) See p. 446.

786

b) What is the probability that you select the six winning numbers in a lottery if the six different winning numbers are selected from the first 50 positive integers? b) 1/C(50, 6) Q2. a) What conditions should be met by the probabilities assigned to the outcomes from a finite sample space?

b) What probabilities should be assigned to the outcome of heads and the outcome of tails if heads comes up three times as often as tails? b) p(H) = 3/4, p(T) = ¼

786

Q3. a) Define the conditional probability of an event E given an event F. a) See p. 456

b) Suppose E is the event that when a die is rolled it comes up an even number, and F is the event that when a die is rolled it comes up 1, 2, or 3.What is the probability of F given E? b) 1/3 Q4. a) When are two events E and F independent? a) See p. 457 The events E and F are independent if and only if p(E ∩ F) = p(E)p(F). EXAMPLE 5 Suppose E is the event that a randomly generated bit string of length four begins with a 1 and F is the event that this bit string contains an even number of 1s. Are E and F independent, if the 16 bit strings of length four are equally likely?

786

Solution: There are eight bit strings of length four that begin with a one: 1000, 1001, 1010, 1011, 1100, 1101, 1110, and 1111. There are also eight bit strings of length four that contain an even number of ones: 0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111. Because there are 16 bit strings of length four, it follows that p(E) = p(F) = 8/16 = 1/2. Because E ∩ F ={1111, 1100, 1010, 1001}, we see that p(E ∩ F) = 4/16 = 1/4. Because p(E ∩ F) = 1/4 = (1/2)(1/2) = p(E)p(F), we conclude that E and F are independent b) Suppose E is the event that an even number appears when a fair die is rolled, and F is the event that a 5 or 6 comes up. Are E and F independent? b) yes Q5. a) What is a random variable? a) See p. 460

b) What are the possible values assigned by the random variable X that assigns to a roll of two dice the larger number that appears on the two dice? b) 1, 2, 3, 4, 5, 6 Q6. a) Define the expected value of a random variable X.

786

b) What is the expected value of the random variable X that assigns to a roll of two dice the larger number that appears on the two dice?

Q7. a) Explain how the average-case computational complexity of an algorithm, with finitely many possible input values, can be interpreted as an expected value. a) See p. 482.

786

b) What is the average-case computational complexity of the linear search algorithm, if the probability that the element for which we search is in the list is 1/3, and it is equally likely that this element is any of the n elements in the list? b) (5n + 6)/3 (see Example 8 in Section 7.4)

Q8. a) What is meant by a Bernoulli trial? a) See p. 458 b) What is the probability of k successes in n independent Bernoulli trials? b) See Theorem 2 in Section 7.2

786

c) What is the expected value of the number of successes in n independent Bernoulli trials? c) See Theorem 2 in Section 7.4

786

Q9. a) What does the linearity of expectations of random variables mean? a) See p. 480.

786

b) How can the linearity of expectations help us find the expected number of people who receive the correct hat when a hatcheck person returns hats at random? b) See Example 6 in Section 7.4.

Q10. a) How can probability be used to solve a decision problem, if a small probability of error is acceptable? a) See the discussion of Monte Carlo algorithms on p. 463

786

b) How can we quickly determine whether a positive integer is prime, if we are willing to accept a small probability of making an error? b) See Example 16 in Section 7.2.

786

Q11. State Bayes’ theorem and use it to find p(F | E) if p(E | F) = 1/3, p(E | ‘F) = 1/4, and p(F) = 2/3, where E and F are events from a sample space S.

786

Q12. a) What does it mean to say that a random variable has ageometric distribution with parameter p? a) See pp. 484-485

786

786

b) What is the mean of a geometric distribution with parameter p? b) See Theorem 4 in Section 7.4. دغه پورته څلورمه قضيه ده Q13. a) What is the variance of a random variable?

786

b) What is the variance of a Bernoulli trial with probability p of success? b) See Example 14 in Section 7.4.

Q14. a) What is the variance of the sum of n independent random variables?

786

b) What is the variance of the number of successes when n independent Bernoulli trials, each with probability p of success, are carried out?

b) See Example 18 in Section 7.4. 18 دغه پورته مثال دی Q15. What does Chebyshev’s inequality tell us about the probability that a random variable deviates from its mean by more than a specified amount? See p. 491.

786

Special Thanks from Azizullah ‘Mahjoor’ that help me for solving these Question Prepared by Samiullah ‘Yousafi’ Solved by Samiullah Yousafi & ‘Azizullah Mahjoor’ Students of Kandahar Computer Science Faculty 1395-02-27

Monday, May-16-2016