Download Test 3 review answers

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Location arithmetic wikipedia , lookup

Positional notation wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Arithmetic wikipedia , lookup

Large numbers wikipedia , lookup

Real number wikipedia , lookup

Elementary arithmetic wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Naive set theory wikipedia , lookup

Order theory wikipedia , lookup

Transcript
Test 3 review answers
Spring 2011
1. Let A = {a, b, c} and let B = {a, c, d}. Define a relation R between (A) and (B) by
(C, D)  R if C  D. List all ordered pairs in R.
Subsets of A are
Subsets of B are

1. 
{a}
2. {a}
{b}
3. {c}
{c}
4. {d}
{a, b}
5. {a, c}
{a, c}
6. {a, d}
{b, c}
7. {c, d}
{a, b, c}
8. {a, c, d}
For ease of discussion the sets in (B) have been numbered. The following are the
subset relationships defined on the power sets:
 is a subset of all sets in (B) (8 ordered pairs)
{a} is a subset of 2, 5, 6, and 8 (4 ordered pairs
{b} is not the subset of any set in (B)
{c} is the subset of 3, 5, 7, 8 (4 ordered pairs)
{a, b} is not the subset of any set in (B)
{a, c} is the subset of 5 and 8 (2 ordered pairs)
{b, c} is not the subset of any set in (B)
{a, b, c} is not the subset of any set in (B)
2. Let S = {1, 2, 3, 4}. Define a relation R on S as follows: (i, j)  R if i + j is a divisor of 12.
a. List all ordered pairs in R.
(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 4), (3, 1), (3, 3), (4, 2)
b.
1
1
1
0
c.
Give the matrix representation of R.
1 1 0
1 0 1
0 1 0
1 0 0
Find RοR Includes all elements of S  S except (3, 4) and (4, 3)
3. If possible, give an example of a relation R on S = {a, b, c} for which R has exactly 3
elements and is both symmetric and transitive but not reflexive. If it’s not possible, explain
why not.
This is not possible. Since it can’t be reflexive and must have three pairs then there
must be a pair in which the two elements are not the same. Suppose that (a, b) R.
Then symmetry means (b, a)  R and transitivity means that both (a, a) and (b, b)
must be in R also. Thus, the smallest relation satisfying those conditions has four
ordered pairs.
4. Consider the following three relations. For each relation, place its number in the blank to
the left of each property it satisfies.
Relation 1: R = {(a, b) N  N | a + b is even}
Relation 2: R = {(a, b) | a, b  Z and |a - b|  1}
Relation 3: R = 
_____1, 2_____ Reflexive ___1, 2, 3_____ Symmetric __1, 3_______ Transitive
______3_____ Irreflexive ______3_____ Antisymmetric ____3_______ Asymmetric
5. S = {A, B, C, D, E} is a set of functions. Let A1 and A2 be elements of S and let R be the
relation on S defined by (A1, A2)  R if A1 calls A2.
A calls B, A calls C, B calls C, C calls E, D calls C, E calls B.
a. List all ordered pairs in R.
R = {(A, B), (A, C), (B, C), (C, E), (D, C), (E, B)}
b. Find the transitive closure of R
{(A, B), (A, C), (B, C), (C, E), (D, C), (E, B), (A, E). (B, E), (C, B), (B, B), (E, E), (C, C), (E,
C), (D, E), (D, B)}
c. A function is recursive if it can directly or indirectly call itself. Does S contain any
recursive functions?
Yes, B, C, and E
6. Prove or disprove that if R is a transitive relation on set A, then R' is transitive also.
Not true, here’s a counterexample:
Let A = {a, b, c} and let R = {(a, b)}. Clearly R is transitive since it contains only one
element. Then ordered pairs (a, c) and (c, b) are in R'. If R' were transitive then
(a, b) would have to be in R' which is not possible since it’s in R.
7. Program A uses one second on 30 data items and has complexity c•n2 for n items. How
many seconds would the program take for 50 data items? Leave your answer as a
fraction in lowest terms.
c•302 = 1 second so c = 1/900. Then c•502 = 2500/900 = 25/9
8. How many times is the assignment statement in the while loop executed? __lg n____
in
while i  1 do
i  i/2
9. Solve the following recurrence relation. Be sure to show the entire solution, including
summations, if appropriate, before computing the sum.
f(n) = 3f(n/3) + n and f(1) = 1
f(n) = 3f(n/3) + n
= 3[3f(n/9) + n/3] + n = 32f(n/9) + n + n
= 32[3f(n/27) + n/9) + n + n = 33f(n/27) + n + n + n
Making the standard assumption that n = 3k, we have
f(n) = 3k f(1) + k•n
Since k = log3n we have
f(n) = n + n log3n
10. If C(n, 8) = C(n, 5) then n = ____13_________
11. Matching exactly three white balls in the powerball lottery wins a prize. How many
powerball tickets are there for which exactly three white balls (and not the powerball) are
matched?
On any ticket 5 numbers corresponding to white balls and one corresponding to
the powerball must be chosen. This means that for a ticket to win in this way
exactly three correct and two incorrect white numbers must be chosen as well as
an incorrect powerball number. So, the number of ways to correctly choose 3 of
the 5 winning numbers is C(5, 3). Of the 50 nonwinning numbers, two losing
numbers must be picked. This can be done in C(50, 2) ways. Finally, there are 41
ways to choose an incorrect powerball so the total number of tickets satisfying
these conditions is the product of those values: C(5, 3)•C(50, 2)•41.
12. Consider the set of bit strings of length 10. How many
a. contain exactly three 0's? C(10, 3)
b. begin or end with 0 29 + 29 – 28 or 210 - 28
c. contain at least two 0's?
210  11 (Total number  no 0's  exactly one 0)
13. How many three-digit numbers are there in which the sum of the digits is even?
450—first note there are 900 three digit numbers. Let’s look at them in blocks of
10. For example, 100 – 109, 110 – 119, etc. Notice that no matter what the first two
digits are, the last digit will determine whether the sum is odd or even. Since five
of the digits from 0 – 9 will make the sum even and half will make it odd, then ½ of
the three-digit numbers or 450 numbers have even sums.
14. A group of n men and n women are arranged in a row. The number of arrangements with
a. the men and women in any order is __(2n)!_____
b. the men and women in alternate places is
2·n!·n! (The 2 is to determine if first chair contains a man or a woman.)
c. The men occupying n consecutive seats (n+1)•n!•n!
n+1 chairs the first man could sit in, n! arrangements for men, n! arrangements for women
15. A test has two parts. Part 1 has 6 questions and part 2 has 4. A student must answer a
total of 6 questions with at least two from each part. In how many ways can the questions
that are answered be selected?
C(6, 2)•C(4, 4) + C(6, 3)•C(4, 3) + C(6, 4)•C(4, 2)
2 from part 1
3 from each part 4 from part 1
4 from part 2
2 from part 2
16. A coin is tossed eight times. An outcome is string of 8 made up of T and H.
a. How many outcomes have a head on the fifth toss?
27
b. How many outcomes have equal numbers of heads and tails? C(8, 4)—since there
must be equal numbers of each, you just have to choose the positions for the
heads.
Since the heads are indistinguishable combinations rather than
permutations are needed.
17. A class contains 30 students--10 freshmen, 12 sophomores and 8 juniors.
a. The number of committees with exactly one person from each class is 10•12•8
b. The number of ways to arrange the students in a line so that all the freshmen are
together at the front of the line is 10! x 20!
18. Write a pseudocode algorithm that returns the index of the first item that is greater than its
predecessor in the array[a1, a2, ..an]. Output 0 if the numbers are in nonincreasing order.
Give the number of comparisons made in the best and worst cases. Note: other
answers are possible. Just be careful to check all the exceptional cases.
int i  1
int bigger  0
while (i < n and ai  ai+1)
ii+1
if i < n then bigger  i+1
return(bigger)
First, a couple of comments. In the while loop, the i < n test is necessary to ensure
there are list items remaining. If we drop out of the while loop on the first condition it
means that the list is in nonincreasing order. If a number greater than its predecessor
is found, we drop out of the while loop and at that point ai < ai+1 so we want to return
i+1, the index of the first item greater than its predecessor.
Best case: a2 > a1 so the number of comparisons is 3—two in the while
loop and one in the if statement.
Worst case: the list is in nonincreasing order. The number of comparisons
is then 2(n-1) + 1 + 1 = 2n because there are two comparisons each time
through the while loop plus one more (when i = n) to drop out of the loop
and one in the if statement.