16
1 CSC 125 :: Final Exam December 14, 2011 1-5. Complete the truth tables below: p q p q p q p q p q p q T T T T F T T T F F T T F F F T F T T T F F F F F F T T (6 – 9) Let p be: Log rolling is fun. q be: The sawmill is closed. Express these as English sentences: 6. p q Log rolling is not fun or the sawmill is closed. 7. q p If log rolling is not fun then the sawmill is closed. Write these propositions using p and q and logical connectives: 8. The sawmill is not closed but logrolling is fun. q p 9. If logrolling is not fun then the sawmill is not closed. p q

CSC 125 :: Final Exam - Kutztown University of …faculty.kutztown.edu/rieksts/125/study/fall11/Exam-ans.pdf · 1 CSC 125 :: Final Exam December 14, 2011 1-5. Complete the truth tables

  • Upload
    vocong

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

1

CSC 125 :: Final Exam December 14, 2011

1-5. Complete the truth tables below:

p q p q p q p q p q p q

T T T T F T T

T F F T T F F

F T F T T T F

F F F F F T T

(6 – 9) Let

p be: Log rolling is fun.

q be: The sawmill is closed.

Express these as English sentences:

6. p q

Log rolling is not fun or the sawmill is closed.

7. q p

If log rolling is not fun then the sawmill is closed.

Write these propositions using p and q and logical connectives:

8. The sawmill is not closed but logrolling is fun.

q p

9. If logrolling is not fun then the sawmill is not closed.

p q

2

(12 – 15) Match the following logical equivalences with the answers found in the

Answer Bank. Write the correct letter just to the right of the ≡ symbol.

Note: Some answers will be used more than once:

12. Domination Laws p T ≡ T A

p F ≡ F B

13. Identity Laws p T ≡ p C

p F ≡ p C

14. DeMorgan's Laws (p q) ≡ p q M

(p q) ≡ p q N

15. Negation Laws p p ≡ T A

p p ≡ F B

(16 – 18) Fill in the missing portion of each of the rules of inference named below:

16. Modus ponens (affirming the hypothesis) p → q

p .

q

17. Modus tollens (denying the conclusion) p → q

q .

p

18. Hypothetical syllogism p → q

q → r

p → r

(19 – 22) Determine whether the arguments below are valid or invalid, then circle

either Valid or Invalid. If valid, using the list of valid argument forms found in the

Answer Bank, write the letter of the rule of inference; if invalid write the letter of

the logical fallacy, again using the list of invalid argument forms found in the

3

Answer Bank.

19. Freedom is precious and fragile.

Freedom is fragile.

Valid Invalid

Valid – simplification F

20. If Tyler has bronchitis, then has a fever.

Tyler has a fever.

Tyler has bronchitis.

Valid Invalid

Invalid – affirming the conclusion I

21. Sam is really smart.

Sam is really smart and he gets good grades.

Valid Invalid

Invalid – unwarranted addition K

22. Logic is either hard or it is nutty.

Either logic is easy or it is impossible.

Logic is either nutty or it is impossible.

p q

p r

q r

Valid Invalid

Valid – resolution

(23 – 24) Let the domain of P(x) consist of the integers 1, 2 and 3. Write out each

proposition using disjunctions, conjunctions and negations.

23. x P(x)

P(1) P(2) P(3)

24. x P(x)

P(1) P(2) P(3)

4

(25 – 32) Let S(x) be the statement “person x stands during the 7th

inning stretch,”

where the domain for x consists of all persons who go to baseball games.

(25 – 28) Write the sentence which renders the logical expression into colloquial

English.

25. x S(x)

Everyone stands during the 7th

inning stretch

26. x S(x)

Someone stands during the 7th

inning stretch

27. x S(x)

Someone does not stand during the 7th

inning stretch

Someone sits during the 7th

inning stretch

28. x S(x)

Everyone sits during the 7th

inning stretch

No one stands during the 7th

inning stretch

(29 – 32) Render the sentences below as logical expressions, using predicates and

quantifiers.

29. Some stand during the 7th inning stretch.

x S(x)

30. Some do not stand during the 7th

inning stretch.

x S(x)

x S(x)

31. Not everyone stands during the 7th inning stretch.

x S(x)

x S(x)

32. Micah stands during the 7th

inning stretch.

S(Michah)

(33 – 35) Let F(x,y) be the statement “x can fool y,” where the domain for both x and

y consists of all people in the world. Use quantifiers to express these sentences.

33. Everyone can fool Fred.

5

xF(x,Fred)

34. Someone can fool everybody.

xyF(x,y)

35. No one can fool him- or herself.

xF(x,x) ≡ xF(x,x)

(36 – 43) Let D(x,y) be the statement “student x does homework assignment y,”

where the domain for x consists of all students in this class and the domain for y

consists of all homework assignments.

(36 – 39) Render these logical expressions into colloquial English.

36. xy D(x,y)

Someone did a homework assignment

37. x y D(x,y)

Every did every homework assignment

38. xy D(x,y)

Everyone did a homework assignment

39. yx D(x,y)

Every assignment was skipped by someone

= There is no assignment done by everyone

(40 – 43) Write the logical expression – using nested quantifiers – for each sentence

below.

40. Some students did some of the assignments.

x y D(x,y)

41. No one did every assignment.

x y D(x,y)

x y D(x,y)

42. Some did every assignment.

x yD(x,y)

43. Dana did not do any assignment.

y D(Dana,y)

6

y D(Dana,y)

(44 – 46) Match the following set identities – write the letter of the correct answer

found in the Answer Bank.

44. Identity Laws A = A

A U = A

45. Domination Laws A U = U

A =

46. DeMorgan's Laws cmp(A B) = cmp(A) cmp(B)

cmp(A B) = cmp(A) cmp(B)

(47 – 50) Let A = {1, 3, 5, 7} B = {1, 2, 7}

C = { 2, 6, 8}

47. A B = {1, 2, 3, 5, 7}

48. A – B = {3, 5}

49. A – (B C) = B C = {1, 2, 6, 7, 8} => {3, 5}

50. A B = {2, 3, 5}

51. Let

A = {1, 2, 3}

Give the power set of A.

P(A) = {, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}

OR:

000 001

010

7

011

100 101

110 111

{, {3}, {2}, {2,3}, {1}, {1,3}, {1,2}, {1,2,3}}

52. Let

A = {a,b,c}

B = {x,y}

A B = {(a,x), (a,y), (b,x), (b,y), (c,x), (c,y)}

(53 – 58) Circle True or False

53. x{x} True False

54. x {x} True False The only subsets of {x} are and {x}, but not x.

55. {x} {x} True False

Every set is a subset of itself.

56. {} True False

57. {} True False

The null set is a subset of every set.

58. { {} True False

The only element of {} is which is not the same as {}.

(59 – 61) Let the universal set

U = {a, b, c, d, e, f, g, h}, and

A = {a, c, e, f}

B = {b, c, e, g}

59. Give the bit string for A B. 00101000

10101100 01101010

00101000

60. Give the bit string for A B. 11000110

8

10101100

01101010 11000110

61. Give the bit string for the complement of A. 01010011

10101100

01010011

(62 – 65) Compute the value of these expressions involving the floor and ceiling

functions.

62. 5/2

= 2

63. 5/2

= -3

64. 5/2

= 3

65. 5/2

= -2

(66 – 68) What is the cardinality of each of these sets, assuming a and b are distinct

elements?

66. P({a}) 2|{a}| =21 =2

67. P({a, b}) 2|{a,b}| =22 =4

68. P() 2|| =20 =1

(69 – 71) For each function defined below, determine whether it is one-to-one, onto,

both, or neither.

69. Let

A = {a, b, c, d}

B = {1, 2, 3}

f : A B

f(a) = 3; f(b) = 2; f(c) = 1; f(d) =2

one-to-one onto

70. Let

9

A = {a, b, c}

B = {1, 2, 3}

f : A B

f(a) = 3; f(b) = 1; f(c) = 2

one-to-one onto => both

71. Let

A = {a, b, c}

B = {1, 2, 3, 4}

f : A B

f(a) = 2; f(b) = 1; f(c) = 3

one-to-one onto

(72 – 75) Determine for each function f: Z Z whether it is one-to-one, onto,

neither or both:

72. f(n) = n – 1 Both

73. f(n) = n2 +1 Neither: not 1-1 because f(1) = f(-1); not onto because no

negative values are in the range.

74. f(n) = n3 1-1, but not onto (e.g., 2 is not in the range)

75. f(n) = n/2 Not 1-1, since f(1) = f(2); onto, since f(2m) = m.

(76 – 78) What are the terms a0, a1, a2, and a3, of the sequence {an}, where an

equals:

76. 2n + 5*3n

[20 + 5*30], [21 + 5*31], [22 + 5*32], [23 + 5*33] = [1 + 5], [2 + 5*3], [4 + 5*9], [8 + 5*27]

= 6, 17, 49, 143

77. 2n – (–2)n [20 – (–2)0], [21 – (–2)1], [22 – (–2)2], [23 – (–2)3]

= [1 – 1], [2 – (–2)], [4 – 4], [8 – (–8)] = [1 – 1], [2 + 2], [4 – 4], [8 + 8]

= 0, 4, 0, 16

78. 2n/3

0/3, 2/3, 4/3, 6/3

= 0, 0, 1, 2 SEQUENCES!!

10

(79 – 82) For the questions below, the notation:: n

j=0 x represents the summation

of x as j goes from 0 to n.

(79 – 80) What are the values of these sums?

79. 5

k=0 (k+3)

(0+3) + (1+3) + (2+3) + (3+3) + (4+3) + (5+3) = 3 + 4 + 5 + 6 + 7 + 8

= 33

80. 4

j=0 2j

2*0 + 2*1 + 2*2 + 2*3 + 2*4 = 0 + 2 + 4 + 6 + 8

= 20

(81 – 82) Compute each of these double sums.

81. 4

i=0 3

j=1 (i – j)

4

i=0 (i-1) + (i-2) + (i-3) = 4

i=0 3i-6

= (3*0 – 6) + (3*1 – 6) + (3*2 – 6) + (3*3 – 6) + (3*4 – 6)

= – 6 – 3 + 0 + 3 + 6

= 0

82. 3

i=0 2

j=0 (2i+3j)

3

i=0 (2i + 3*0) + (2i + 3*1) +(2i + 3*2)

= 3

i=0 (2i + 0 + 2i + 3 + 2i + 6)

= 3

i=0 (6i + 9)

= (6*0 + 9) + (6*1 + 9) + (6*2 + 9) + (6*3 + 9) = 6*6 + 4*9 = 36 + 36

= 72

83. Let S = {1, 2, 4, 7}

What is j S (j2 – 2j)?

j S (j2 – 2j) = (12 – 2*1) +(22 – 2*2) +(42 – 2*4) +(72 – 2*7)

= (1 - 2) + (4 - 4) + (16 - 8) + (49 - 14)

= -1 + 0 + 8 + 35

= 42

84. Arrange the Big-O categories below in ascending order O(n)

O(n log n)

11

O(nn)

O(nk)

O(bn)

O(1)

O(n!)

O(log n)

O(1), O(log n) , O(n), O(n log n), O(nk), O(b

n) , O(n!) , O(n

n)

85. What is the runtime Big-O classification of GenPerms?

O(n!) :: factorial

86. What is the space usage Big-O classification of GenPerms?

O(n2) :: polynomial

87. If GenPerms were run on an input of abcdefghijklmnopqrstuvwxyz would the run

time be best expressed in seconds, minutes, hours, days, weeks, months, years or

centuries? centuries

88. State the number theory theorem that allowed us to greatly reduce both the time

and the space required for modular exponentiation.

ab mod m = ((a mod m)(b mod m)) mod m

89. Find a div m and a mod m when: a = 228, m 119

1, 109

90. Find a div m and a mod m when: a = 9009, m = 223

40, 89

91. List all the integers between -20 and +20 that are congruent to 4 modulo 7.

–17, –10, –3, 4, 11, 18

92. (455 mod 23 + 173 mod 23) mod 23 =

(18 + 12) mod 23 = 30 mod 23 = 7

93. (455 mod 23 * 173 mod 23) mod 23 =

(18 * 12) mod 23 = 216 mod 23 = 9

(94 – 105) You may use the number bases table in the Appendix.

94-96. Convert from decimal to binary, octal and hexadecimal: 231

12

1110 0111, 347, E7

97-99. Convert from binary to octal, hexadecimal, and decimal: 10010012

111, 49, 73

100-102. Convert from octal to binary, hexadecimal, and decimal: 3258

1101 0101, D5, 213

103-105. Convert from hexadecimal to binary, octal, and decimal: AB516

1010 1011 0101, 5265, 2741

106. Give the prime factorization of 88

23*11

107. Give the prime factorization of 14553

33*72*11

108. Which positive integers < 20 are relatively prime to 20?

20 = 22*5, so any multiple of 2 or 5 is NOT rel. prime to 20 1, 3, 7, 9, 11, 13, 17, 19

109. Give the gcd of 37*5

3*7

3 and 2

11*3

5*5

9

35 *53

110. Give the lcm of of 37*5

3*7

3 and 2

11*3

5*5

9

211*37*59*73

111. There are 13 math majors and 127 CS majors. In how many ways can you pick

2 reps such that 1st is a math major and 2

nd is a CS major?

13*127 = 1651

112. There are 13 math majors and 127 CS majors. In how many ways can you pick

one who is either a math major or a CS major?

13 + 127 = 140

113. How many different 3 letter initials can people have?

263

114. How many bit strings are there of length 8?

28 = 256

13

115. How many bit strings are there of length 12 that both begin and end with 1?

210 = 1024

116. How many bit strings of length 10 are palindromes?

25

117. How many ways are there to seat 6 people around a circular table if two

seatings are the same as long as each person has the same right and left neighbor?

(6-1)! = 5! = 120

118. How many bit strings of length 10 either begin with 3 zeros or end with 2

zeros?

352 Begin: 27 = 128 End: 28 = 256 Both: 25 = 32 Total = 128 + 256 – 32 = 352

119. Out of a bowl with 10 red and 10 blue balls, how many must you select to be

sure to have 3 of the same color?

5 – if you pick only 4, you might have 2 blue & 2 red

120. Out of a bowl with 10 red and 10 blue balls, how many to be sure you have at

least 3 blue ones?

13 – the first 10 might all be red.

121. How many students must be enrolled at a university in order to guarantee that at

least 1000 come from the same state?

50*999 + 1 = 49951

122. List all permutations of {a, b, c}.

abc, acb, bac, bca, cab, cba

123. How many different permutations are there of {a, b, c, d, e, f, g}?

7! = 5040

(124 – 127) Give the value of these r-permutations and r-combinations:

124. P(6,3)

6!/3! = 720/6 = 120

125. P(8,5)

14

8!/3! = 6720

126. C(6,3)

6!/3!3! = 20

127. C(8,5)

8!/5!3! = 56

128. How many possibilities for win, place & show in a race with 12 horses?

P(12,3) = 12!/9! = 12*11*10 = 1320

129. How many bit strings of length 10 contain exactly four 1s?

C(10,4) = 10!/4!*6! = 10*9*8*7/4! = 10*9*8*7/24 = 210; each of the 1s can be place in any of the 10 positions, order does not matter.

130. How many bit strings of length 10 contain at most four 1s?

Either 0, 1, 2, 3 or 4 1s C(10,0) + C(10,1) + c(10,2) + C(10,3) + C(10,4) = 10!/0!*10! + 10!/1!*9* + 10!/2!*8! + 10!/3!*7! + 10!/4!*6! = 1 + 10 + 45 + 120 + 210 = 386

131. A coin is flipped 10 times. How many possible outcomes are there in total?

Notice that this is the same as asking questions about bit strings of length 10, with heads being 1s and tails being 0s. 210 = 1024

132. A coin is flipped 10 times. How many possible outcomes contain exactly 2

heads?

C(10,2) = 10!/2!*8! = 45

133. What is the probability that a fair die never comes up even when it is rolled 6

times?

This is the probability that it comes up odd 6 times in a row; (½)6 = 1/64

Extra Credit

EC-1. Give the probabilities, when rolling a pair of fair dice, of rolling each of the

sums 2, 3, 4, . . , 10, 11, 12.

ANSWER:

15

If you roll a pair of dice, what is the probability that they will sum to . .

a) 2

b) 3

c) 4

d) 5

e) 6

f) 7

g) 8

h) 9

i) 10

j) 11

k) 12

a) 1 & 1 1/36 b) 1 & 2; 2 & 1 2/36 = 1/18 c) 1 & 3; 3 & 1; 2 & 2 3/36 = 1/12 d) 1 & 4; 4 & 1; 2 & 3; 3 & 2 4/36 = 1/9 e) 1 & 5; 5 & 1; 2 & 4; 4 & 2; 3 & 3 5/36 f) 1 & 6; 6 & 1; 2 & 5; 5 & 2; 4 & 3; 3 & 4 6/36 = 1/6 g) 2 & 6; 6 & 2; 3 & 5; 5 & 3; 4 & 4 5/36 h) 3 & 6; 6 & 3; 4 & 5; 5 & 4 4/36 = 1/9 i) 4 & 6; 6 & 4; 5 & 5 3/36 = 1/12 j) 5 & 6; 6 & 5 2/36 = 1/18 k) 6 & 6 1/36

EC-2. Suppose you have a pair of loaded dice. On one die 2 is twice as likely to

come up as any of the other numbers. On the other die, 5 is 3 times as likely to come

up as any other number. What sum is most likely to occur? Why?

EC-3. How many zeros are at the end of 10000!

10000 div 5 + 10000 div 52 + 10000 div 53+ 10000 div 54 + 10000 div 55

= 2000 + 400 + 80 + 16 + 3 = 2499

EC-4. List all the twin primes between 100 and 200.

101,103 107,109 137,139 149,151 179,181 191,193 197,199

EC-5. Consider the base 32 number system. As with hexadecimal we can use letters

of the alphabet for the values 10, 11, etc. [Use instead of the letter O which looks

too much like the digit 0].

16

a. What is the largest digit you will have to represent? What letter will be

used to represent it?

b. Give the binary, octal, hexadecimal and decimal representation of

CPU32.

c. of R2D232.

d. Give the base 32 representation of 9090910.

a. Largest is 31 represented by V. b. C = 12 -> 01100; P = 26 -> 11010; U = 30 -> 11110. Thus, binary is

011001101011110; octal is 31536; hex is 335E; decimal is 13150 c. R = 18 -> 10010; 2 = 2 -> 00010; D = 13 -> 01101; 2 = 2 -> 00010. Thus,

binary is: 100100001001101 00010; octal is 44115; hex is 484D; decimal is 18509

d. 90909 = 10 11000 11000 11101 -> 2-24-24-29 -> 2T

EC-6. We know that 2/5 in base 10 is the terminating decimal 0.4, while 1/3 is the

repeating decimal 0.3333. It turns out that in base 2 the fraction ½ is the terminating

“binimal” 0.1, but 2/5 is the repeating one 0.011001100. It stands to reason that in

base 6 the fraction 1/6 terminates, since the denominator is the base itself. On the

other hand, 2/5 repeats as it did in base 2 – 0.222.

Give some other examples of fractions that terminate in base 10 but repeat in

base 6;

that terminate in base 6 but repeat in base 10;

that terminate in both base 6 and base 10;

that repeat in both base 6 and base 10.

What about fractions in base 7 vis a vis base 10?

Bases 6 & 10 – in common denominators that are powers of 2; terminate in 10 but not in 6 – denominators that are powers of 5; terminate in 6 but not in 10 – denominators that are powers of 3. Base 7 – none in common. Only those with denominators powers of 7 terminate.