Assignment1.pdf - MATH 340  Discrete Stuctures 2  Winter 2019 Assignment 1 Due date Thursday February 7 2019 at 4:05 Solutions You can work out the

Assignment1.pdf - MATH 340  Discrete Stuctures 2  Winter...

This preview shows page 1 out of 6 pages.

Unformatted text preview: MATH 340  Discrete Stuctures 2  Winter 2019 Assignment 1 Due date: Thursday, February 7, 2019 at 4:05. Solutions You can work out the problems with your friends, but every student must submit their own solutions, written in their own words: otherwise it may be considered as plagiarism. Late submissions will be penalized by 10% o per day after the deadline. Paper submissions (in class) are strongly encouraged. Question 1 (20 marks) A website asks you to login in order to be able to write on its guestbook. But of course, it won't let you choose just any string as a password: that would be too simple! Instead, the requirements are the following: 1. The password must contain between 8 and 10 characters. 2. Each character must be of one of the following types: lowercase letters without accents (az), uppercase letters without accents (AZ), digits (09) or special characters from the following list: !?#&@%*~$_ 3. The password contains at least one character of at least three of the four types mentioned above. In how many ways can a password be chosen in order to meet all those requirements? That way of thinking about internet security is completely obsolete, but somehow still common. XKCD has a comic strip about that... See Note: Solution: Let's rst name and count each set of characters... L = {Lowercase letters} U = {Uppercase letters} D = {Digits} S = {Special characters} |L| = 26 |U | = 26 |D| = 10 |S| = 10 Let pk be the number of valid passwords, for k = 8, 9, 10. We will count each pk separately, so that by the sum principle, the total number of valid passwords is p8 + p9 + p10 . There are 2 × 26 + 2 × 10 = 72 admissible characters in total, so 72k possible strings of length k, and from that, we want to subtract the number qk of strings that just use one or two types of characters. So pk = 72k − qk by the complement principle. Now, to count qk , we need to split in cases according to the two sets of characters that are used. • |L ∪ U | = 52, so there's 52k strings made just with lowercase and uppercase letters. • |D ∪ S| = 20, so that's 20k strings made just with digits and special characters. • |L ∪ D| = |L ∪ S| = |U ∪ D| = |U ∪ S| = 36, so that's 36k strings made just with two of those types of characters, for each of the four possibilities. Note that the strings made with just one type of character were counted exactly 3 times in the cases above, for each type of chracter. So we need to remove two times the (26k + 26k + 10k + 10k ) strings made of just one type of character from the total above in order to count them just once. Combining all of this together, we nd: pk = 72k − qk = 72k − 52k − 20k − 4 · 36k + 4 · 26k + 4 · 10k . Substituting values for k, we nd p8 = 658270076405760, p9 = 48833762118635520 and p10 = 3585280971297792000, for a total of 3634773003492833280 valid passwords. Question 2 (20 marks) A wedding organizer needs to sit 4 couples and 4 single persons around a round table. In how many ways can she sit those 12 people so that: (a) All couples sit together (the two members of each couple sit side-by-side)? (b) No couple sit together? Hint: Inclusion-Exclusion... Since the table is round, dierent rotations of the same arrangement are indistinguishable, but a clockwise arrangement is distinguishable from its counterclockwise version. Note: A D D B = C C D A 6= A B C B Solution: (a) Let us compute the number N (k) of ways for k couples to sit together, then we will just need to set k = 4 to answer the question. To handle the dierent rotations of the table, let us x the position of one of the four single people, and sit everyone else starting from the right of that person (so it's like sitting them on a row). If k couples are to sit together, each of them can have a conguration M F or F M , so that's 2 options for each: 2k options. Once this is decided, we can see each couple as forming a single block, along with the (11−2k) people that do not belong to any of those k couples. So that's k+(11−2k) = 11 − k blocks to place on a line, and there's (11 − k)! ways to do that. Therefore, N (k) = 2k (11 − k)!. With k = 4, that's 24 (11 − 4)! = 16 × 7! = 80 640 possibilities. (b) Let Ai be the set of congurations of the table such that the i-th couple sit together, for i between 1 and 4. If we take the intersection of any k of those sets together, then the cardinality is the number N (k) calculated in part (a). The number of congurations that belong to none of those sets Ai is then given by the inclusion-exclusion formula: 4 X     4 X 4 k 4 N (k) = 2k (11 − k)! (−1) (−1) k k k=0 k=0 k = 11! − 4 · 2 · 10! + 6 · 4 · 9! − 4 · 8 · 8! + 16 · 7! = 18 385 920 . Question 3 (20 marks) (a) Give an algebraic proof of the following identity.     2n n =2 + n2 2 2 (b) Give a combinatorial proof of the same identity. Solution: (a) Write out the denition in terms of factorials and simplify. The left hand side gives us   2n 2 = 1 · 2n · (2n − 1) = n · (2n − 1) = 2n2 − n 2 The right hand sides gives us   1 n 2 + n2 = 2 · · n · (n − 1) + n2 = n · (n − 1) + n2 = 2n2 − n 2 2 So the two are equal. (b) The LHS is clearly the number of ways to choose two numbers from the set S = {1, 2, 3, . . . , 2n}. Let's see that the RHS also counts this. Divide the set S into A = {1, 2, 3, . . . , n} and B = {n + 1, n + 2, . . . , 2n}. There are  n ways to choose two numbers from A, n2 ways to choose two numbers from B , 2 and n2 ways to choose one number from A and one number from B . This covers all ways to chose two numbers from S . Question 4 (20 marks) Let (a1 , . . . an ) be any nite sequence of n integers. Show that there exist two indices s and t, with 1 ≤ s ≤ t ≤ n, such that t X ai ≡ 0 mod n i=s Hint: You should use the Pigeonhole principle.... Solution: First consider the partial sums where s = 1. That is, sums of the form 1 ≤ t ≤ n. Assume that t X ai ≡ rt Pt i=1 ai , where mod n i=1 If rt = 0 for any 1 ≤ t ≤ n, then we are done. So rt ∈ {1, 2, . . . , n − 1} for each 1≤tP ≤ n. Thus,Pby the pigeon-hole principle, there exist t1 < t2 such that rt1 = rt2 = r. 1 2 ai = ti=1 ai ≡ r mod n. Thus Thus ti=1 t2 X ai − i=1 But the LHS is just Pt2 i=t1 +1 t1 X ai ≡ 0 mod n i=1 ai . So setting s = t1 and t = t2 we have t X ai ≡ 0 mod n i=s Question 5 (20 marks) Use the generating functions method to nd a short formula for the sum of cubes. cn = n X k3 k=0 A(x) If A(x) is the ordinary generating function for the sequence an , then 1−x P is the ordinary generating function for the sequence of partial sums nk=0 ak . So if we nd the ordinary generating function for an = n3 , we can use this trick to get the formula for the sum of cubes. We have ∞ ∞ Solution I. X k=0 k 3 xk = (xD)3 X k=0 xk = (xD)3 1 1−x The expression on the right reduces as follows (xD)3 1 x (1 + x) x3 + 4x2 + x = (xD)2 = (xD) x = 1−x (1 − x)2 (1 − x)3 (1 − x)4 This is our generating function for the cubes. By the argument outlined above, if we multiply this by 1/(1 − x), we nd the generating function for cn . So C(x) = ∞ X cn x n k=0 We saw in class that x3 + 4x2 + x = (1 − x)5  ∞  X 1 n+4 n = x . (1 − x)5 4 n=0 Therefore,  ∞  X n+4 n C(x) = (x + 4x + x) x 4 n=0 ! ! !     ∞  ∞ ∞  X X X n + 4 n+3 n + 4 n+2 n + 4 n+1 = x + 4 x + x 4 4 4 n=0 n=0 n=0   !  !  ! ∞  ∞ ∞  X X X i+1 i j+2 j k+3 k = x + 4 x + x 4 4 4 i=3 j=2 k=1      ∞  X n+1 n+2 n+3 2 = x + 9x + +4 + xn 4 4 4 k=3 3 2 So our expression for the sum of (for n ≥ 3) is n X       n+1 n+2 n+3 k = +4 + 4 4 4 k=0 3 Which, with a little algebra becomes: n X k3 = k=0 n2 (n + 1)2 4 Solution II. Another way to get the closed form for C(x) is with a recurrence. We have c0 = 0 and, for n > 0, ! n n−1 cn = X k=0 k3 = X k=0 k3 + n3 = cn−1 + n3 . Therefore, C(x) = ∞ X cn x n = c0 + n=0 ∞ ∞ X X (cn−1 + n3 )xn = xC(x) + n 3 xn . n=1 n=0 Proceeding the same way as in Solution I, we nd ∞ X n 3 xn = n=0 x3 + 4x2 + x (1 − x)4 Therefore, when we solve the implicit equation above for C(x), we get C(x) = x3 + 4x2 + x (1 − x)5 The rest of the calculations go just like Solution I. ...
View Full Document

  • Fall '09
  • KHARLMPOVICH
  • Summation, Recurrence relation, Generating function, Combinatorial principles

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes