+ All Categories
Home > Documents > CSC 2510 Test 3 1. Give the names of the formula or rule that provides the answer for each of the...

CSC 2510 Test 3 1. Give the names of the formula or rule that provides the answer for each of the...

Date post: 11-Dec-2015
Category:
Upload: gael-roycroft
View: 220 times
Download: 0 times
Share this document with a friend
Popular Tags:
44
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!
Transcript
Page 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!

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!

Page 2: 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.

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 suitsFind: max(suit1 + suit1 + suit1 + suit1) ≤ 3 + 1

Page 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.

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)

Page 4: 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.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.

Page 5: 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.b.

Subtraction rule.

Page 6: 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.c.

How many bit strings of length n are there?

Given: bit strings = 2 choiceslength = n (or repeated n times)bits are indistinguishableeach choice is either a 0 or a 1

Page 7: 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.c.

2n

(two choices for each bit - choicestimes)

Page 8: 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.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: n1 ways + n2 ways

Answer: Sum rule

Page 9: 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.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

Page 10: 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.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

Page 11: 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.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

Page 12: 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.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)

Page 13: 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.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)

Page 14: 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!

3.

What formula would you use in each of the following cases?

Example: permutation: P(n) = n!.

Page 15: 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!

3.a.

A procedure has n1 ways to do task 1 and n2 ways to do task 2:

n1 * n2 or product rule

Page 16: 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!

3.b.

A task may use one of group n1 or one of n2 to do a task:

n1 + n2 or sum rule

(no overlap between groups – all tasks are independent)

Page 17: 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!

3.c.

An ordered arrangement of r elements:

P(n,r) or n!/(n - r)! or n(n-1)(n-2)...(n-r+1)

(r ordered elements out of n)

Page 18: 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!

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 n r times)

Page 19: 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!

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))

Page 20: 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!

3.f.

The number of r-permutations of a set of n objects with repetition:

nr

(Same question as 3.d.)

Page 21: 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!

3.g.

The number of ways to select r items from n indistinguishable objects:(Think cookies).

(the size of r may be greater than, less than, or equal to the size of n)

C(n + r -1, r) or C(n + r - 1, n -1)

or factorial expansion of the aboveC(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!)

Page 22: 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!

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.)

Page 23: 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!

4.a.Give the Euclidean Algorithm for greatest common divisor:

procedure gcd(a, b: positive integers)x := ay := bwhile y 0 r := x mod y x := y y := rreturn x{gcd(a, b) is x}

Page 24: 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!

4.a.or

procedure gcd(a, b: positive integers)x := ay := bif y = 0 return xreturn gcd(y, x mod y)

orprocedure gcd(a, b: positive integers)if b = 0 return areturn gcd(b, a mod b)

Page 25: 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!

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

Page 26: 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!

5.

Let P(n) be the statement that 12 + 32 + 52+ ... + (2n + 1)2 = (n + 1)(2n + 1)(2n + 3)/3

whenever n is a nonnegative integer. Be sure to use the formal proof that includes Basis Step.

Page 27: 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!

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.

Page 28: 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!

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.

Page 29: 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!

6.a.

Give a recursive algorithm (in the pseudo format specified in appendix A3) for computing: n

i=0 i.

procedure series(n; integer) If n = 0 return 0 return n + series (n-1) {returns the sum of the first n values}

Page 30: 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!

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)

Page 31: 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!

7. Answer the following questions.

a. 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.)

Page 32: 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!

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 28 plus 1/4 of 28 minus 1/4 of 1/2 of 22)(areas common to both need to be subtracted out)

Page 33: 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!

8.b.

How many bit strings of length eight either start with a 1 bit or end with the two bits 10?

(1/2 of 28 =) 128 + (1/4 of 28 = ) 64 - (1/4 of 1/2 of 26 = ) 32 = 160

Page 34: 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!

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, ntimes or waysquestions)

Page 35: 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!

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)

Page 36: 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!

10.

Given a set with n items;

a. What formula would you chose to select r items 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) or 20!/(20-3)! or 20*19*18

c. What is that formula called?r-permutations

Page 37: 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!

11.

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

Page 38: 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!

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!)

Page 39: 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!

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.

Page 40: 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!

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) answersIf C(52,5) or 52!/((52-5)! * 5!) or 52! / (47! * 5!) is in answer, accept answer.

Page 41: 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!

12.

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

Page 42: 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!

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!) or52! / (13! 13! 13! 13!)

Page 43: 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!

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.

Page 44: 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!

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.


Recommended