1 / 44

CSC 2510 Test 3

CSC 2510 Test 3. 1. Give the names of the formula or rule that provides the answer for each of the following problems . Do not try to solve the problems!. 1.a.

beckyh
Download Presentation

CSC 2510 Test 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 2510 Test 3 1. Give the names of the formula or rule that provides the answer for each of the following problems. Do not try to solve the problems!

  2. 1.a. How many cards must be selected from a standard deck of 52 cards to guarantee that at least three cards of the same suit are chosen? Givens: Standard deck = 4 suits Find: max(suit1 + suit1 + suit1 + suit1) ≤ 3 + 1

  3. 1.a. max(2 + 2 + 2 + 2) ≤ 3 Answer: Sum rule (Pigeon hole accepted also) max(2 + 2 + 2 + 2) ≤ 3 + 1 = 9 (You can chose 2 (indistinguishable) from each group before the next card will ensure that you have three of a suit)

  4. 1.b. How many bit strings of length eight either start with a 1 bit or end with the two bits 10? There are 28 strings = 256 possible strings. 1/2 of the strings begin with 1 for 128 strings 1/4 of the strings end in 10 for 1/4 * 28 = 64 strings But 1/2 of the 1/4 * 28 for 32 strings also start with 1 so they must be subtracted out again. 128 + 64 - 32 = 160.

  5. 1.b. Subtraction rule.

  6. 1.c. How many bit strings of length n are there? Given: bit strings = 2 choices length = n (or repeated n times) bits are indistinguishable each choice is either a 0 or a 1

  7. 1.c. 2n (two choices for each bit - choicestimes)

  8. 1.d. How many ways can you solve a task if the task can be done in one of n1 ways or in one of n2 ways? Given: n1ways +n2 ways Answer: Sum rule

  9. 2.a. Convert the octal value 7016 to binary. 70168 = 111 000 001 110 Convert the octal digits to binary in groups of three using the table. = 1110000011102

  10. 2.b. Convert the octal value 7016 to hex. 70168 = 111 000 001 110 Convert the octal digits to binary in groups of three using the table. 1110000011102 Then regroup into groups of 4 start from right: 1110 0000 11102 Then convert to hex using table (you should learn the conversion: 1110 0000 11102 = E0E16

  11. 2.c. Convert the octal value 7016 to decimal. 70168 = 7 * 83 + 0 *82 + 1 *81 + 6 *80 = 7 * 512 + 0 + 8 + 6 = 3584 + 8 + 6 = 359810

  12. 2.d. Convert decimal 17861 to hex. 17861/16 = 1116 mod 5 1116/16 = 69 mod 12 = C 69/16 = 4 mod 5 4/16 = 0 mod 4 = 45C516 (remainder of 0 indicates we are finished)

  13. 2.e. Convert decimal 1740 to octal. 1740/8 = 217 mod 4 217/8 = 27 mod 1 27/8 = 3 mod 3 3/8 = 0 mod 3 = 33148 (remainder of 0 indicates we are finished)

  14. 3. What formula would you use in each of the following cases? Example: permutation: P(n) = n!.

  15. 3.a. A procedure has n1 ways to do task 1 andn2 ways to do task 2: n1*n2or product rule

  16. 3.b. A task may use one of group n1or one of n2 to do a task: n1+n2or sum rule (no overlap between groups – all tasks are independent)

  17. 3.c. An ordered arrangement of r elements: P(n,r) orn!/(n - r)! or n(n-1)(n-2)...(n-r+1) (r ordered elements out of n)

  18. 3.d. The number of r-permutations of a set of n objects with repetition: nr (with repetition means that each time you get to choice n items – the amount you can choice never gets smaller than n so that you choice nr times)

  19. 3.e. An unordered selection of r elements from a set with n distinct elements: C(n, r) or n!/(r! * (n-r)!) (unordered is a combination and divides r! back out – (the duplicates))

  20. 3.f. The number of r-permutations of a set of n objects with repetition: nr (Same question as 3.d.)

  21. 3.g. The number of ways to select r items from n indistinguishable objects: (Think cookies). (thesize of r may be greater than, less than, or equal to the size of n) C(n + r -1, r) orC(n + r - 1, n -1) orfactorial expansion of the above C(n + r -1, r) = C(n + r - 1, n -1) because (n+ r-1)/((n+r-1-r)!*r!) = (n+ r-1)/((n-1+(r-r))!*r!) = (n+ r-1)/((n-1)!*r!)

  22. 3.h. The number of ways to select r items from n indistinguishable objects and do it until less than r items remains: C(n,r)C(n-r,r)C(n-r-r,r) * (etc.) (Any expression of same.)

  23. 4.a. Give the Euclidean Algorithm for greatest common divisor: proceduregcd(a, b: positive integers) x := a y := b while y  0 r := x mod y x := y y := r return x {gcd(a, b) is x}

  24. 4.a. or proceduregcd(a, b: positive integers) x := a y := b if y = 0 return x return gcd(y, x mod y) or proceduregcd(a, b: positive integers) if b = 0 return a return gcd(b, a modb)

  25. 4.b. Showing the steps, find gcd(91, 287): 287/91 = 91 * 3 + 14 91/14 = 14 * 6 + 7 14/7 = 7 * 2 + 0 (remainder of 0 indicates we are finished) =7

  26. 5. Let P(n) be the statement that 12 + 32 + 52+ ... + (2n + 1)2= (n + 1)(2n + 1)(2n + 3)/3whenever n is a nonnegative integer. Be sure to use the formal proof that includes Basis Step.

  27. 5. Basis step: Show that P(0) is true. Let n = 0. Then (2(0) + 1)2= ((0) + 1)(2(0) + 1) (2(0) + 3)/3 1= (1)(1)(3)/3 = 1. Since both sides equal 1, P(0) must be true Induction Hypotheses: 12 + 32 + 52 + ... + (2k + 1)2= (k + 1)(2k + 1)(2k + 3)/3 Induction Step: Show that 12 + 32 + 52+ ... + (2k + 1)2 + (2(k+1) + 1)2= ((k + 1) + 1)(2(k + 1) + 1)(2(k + 1) + 3)/3 is true.

  28. 5. Proof: 12 + 32 + 52 + ... + (2k + 1)2+ (2(k+1) + 1)2= ((k + 1) + 1)(2(k + 1) + 1)(2(k + 1) + 3)/3 (k + 1)(2k + 1)(2k + 3)/3 + (2(k+1) + 1)2= ((k + 1) + 1)(2(k + 1) + 1)(2(k + 1) + 3)/3 (k + 1)(2k + 1)(2k + 3)/3 + 3/3 * (2k + 3)2= ((k + 2)(2k + 3)(2k + 5)/3 ((k + 1)(2k + 1)(2k + 3) + 3(2k + 3)2)/3 = ((k + 2)(2k + 3)(2k + 5)/3 (k + 1)(2k + 1)(2k + 3) + 3(2k + 3)2= ((k + 2)(2k + 3)(2k + 5) (k + 1)(2k + 1) + 3(2k + 3) = ((k + 2)(2k + 5) 2k2 + 3k + 1 + 6k + 9 = 2k2 + 9k + 10 2k2 + 9k + 10 = 2k2 + 9k + 10 1 = 1  We have shown that the induction hypotheses is true by showing that the left side equals the right side for k + 1.

  29. 6.a. Give a recursive algorithm (in the pseudo format specified in appendix A3) for computing: ni=0 i. procedureseries(n; integer) If n = 0 return 0 return n + series (n-1) {returns the sum of the first n values}

  30. 6.b. Show the value of ni=0 i generated at each step from 0 to n = 4.  means sum, so each value is added to the previous ( means product, so each value is multiplied to the previous)

  31. 7. Answer the following questions. • How many bit strings of length n are there? 2n Same question as 3.d and 3.f. b. How many bit strings of length 16 are there? 216 (two choices for each bit - choicestimes) • What is the formula that you used? 2n (Same answer as a.)

  32. 8.a.   What rule would you use to compute how many bit strings of length eight either start with a 1 bit or end with the two bits 10? Subtraction rule (1/2 of 28plus 1/4 of 28minus 1/4 of 1/2 of 22) (areas common to both need to be subtracted out)

  33. 8.b. How many bit strings of length eight either start with a 1 bit orend with the two bits 10? (1/2 of 28=) 128 + (1/4 of 28 = ) 64- (1/4 of 1/2 of 26 = ) 32 = 160

  34. 9.a. A multiple-choice test contains 10 questions. There are 4 possible answers for each question. In how many ways can a student answer every question (one answer per question)? (4 ways per question, 10 questions) 410 (10 questions with four choices each, - 410,ntimesor waysquestions)

  35. 9.b. A multiple-choice test contains 10 questions. There are 4 possible answers for each question. In how many ways can a student answer the question on the test if the student can leave answers blank? (5 ways per question, 10 questions)  510 (10 questions with five choices each, - 510)

  36. 10. Given a set with n items; a. What formula would you chose to select ritems in order? P(n, r) or n!/(n-r)! b. How many possibilities would you have with n = 20 and r = 3. P(20, 3) or20!/(20-3)!or 20*19*18 c. What is that formula called? r-permutations

  37. 11. Show formula used reducing factors as much as possible but not necessary to multiply and divide once reduced.

  38. 11.a. How many ways are there to distribute hands of 5 cards to each of four players from the standard deck of 52 cards? (Poker hands) C(52,5)C(47,5)C(42,5)C(37,5) or 52!/((52-5)!5!) * 47!/((47-5)!5!) * 42!/((42-5)!5!) * 37!/((37-5)!5!) = 52! / (47! * 5!) * 47! / (42! * 5!) * 42! / (37! * 5!) * 37! / (32! * 5!) = (52! / (5! * 5! * 5! * 32! * 5! ) = (52! / (5! 5! 5! 5! 32!)

  39. 11.b. For each hand what is the value of (the first n) n? Of r? n1 = 52, r1 = 5 (if in answer, accept) n2 = 47, r2 = 5, n3 = 42, r3= 5, n4 = 37, r4 = 5.

  40. 11.c. Which formula should be used? C(52,5)C(47,5)C(42,5)C(37,5) or accept the following partial (incorrect) answers If C(52,5) or 52!/((52-5)! * 5!) or 52! / (47! * 5!) is in answer, accept answer.

  41. 12. Show formula used reducing factors as much as possible but not necessary to multiply and divide once reduced.

  42. 12.a. How many ways are there to distribute hands of 13 cards to each of four players from the standard deck of 52 cards? (Bridge hands) C(52,13)C(39,13)C(26,13)C(13,13) or 52!/((52-13)! 13!) * 39!/((39-13)! 13!) * 26!/((26-13)! 13!) * 13!/((13-13)!13!) = 52! / (39! 13!) * 39! / (26! 13!) * 26! / (13! 13!) * 13! / (0! 13!) = 52! / (1! 13!) * 1! / 1! 13!) * 1! / (1! 13!) * 1! / (0! 13!) or 52! / (13! 13! 13! 13!)

  43. 12.b For each hand what is the value of n? Of r? n1 = 52, r1 =13, n2 = 39, r2 =13, n3 = 26, r3 =13, n4 = 13, r4 =13 If C(52,13) or 52!/((52-13)! * 13!) is in answer, accept answer.

  44. 12.c. Which formula should be used? r-combinations or C(52,13)C(39,13)C(26,13)C(13,13) or If C(52,13) or 52!/((52-13)! * 13!) is in answer, accept answer.

More Related