Discrete 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Write the next 5 permutations in lexicographic order immediately following (2, 3, 4, 1)

(2,4,1,3), (2,4,3,1), (3,1,2,4), (3,1,4,2), (3,2,1,4)

In the proof for the sum of squares, the inductive hypothesis for any natural number is: P( n): 0 2 + 1 2 + 2 2 + ... + n 2 = n( n + 1)(2 n + 1)/6, n ≥0.If n = 0, then the left-hand side of P(0) = 0 2 = 0, and right-hand side of P(0) = 0 × (0 + 1)(2 × 0 + 1)/6 = 0 . What is the right-hand side of P( n+1)? n(n + 1)(2n + 1)/2 (n + 1)(2n2 + 3n + 6)/6 (n + 1)(n + 2)(2n + 3)/6 n(n + 1)(2n + 3)/6 + (n + 1)2

(n + 1)(n + 2)(2n + 3)/6

Steps of RSA Encryption

1. Choose two distinct prime numbers p and q. 2. Find n such that n = p*q. n will be used as the modulus for both the public and private keys 3. Find the totient of n, ϕ(n) ϕ(n)=(p-1)(q-1) 4. Choose an e such that 1 < e < ϕ(n), and such that e and ϕ(n) share no divisors other than 1 (e and ϕ(n) are relatively prime).e is kept as the public key exponent 5. Determine d (using modular arithmetic) which satisfies the congruence relation d*e ≡ 1 (mod ϕ(n)) This is often computed using the Extended Euclidean Algorithm, since e and ϕ(n) are relatively prime and d is to be the modular multiplicative inverse of e.d is kept as the private key exponent e = 61, ϕ = 616 61x + 616y = 1 -> do euclidean on this and find the variable associated with e so x in this case which will be 101 and then d = 101 mod N 6. The public key has modulus n and the public (or encryption) exponent e. The private key has modulus n and the private (or decryption) exponent d, which is kept secret. Encrypt - c ≡ m^e (mod n) Decrypt - m ≡ c^d (mod n)

Order of functions in fastest order

100 log10 n 10n n·logn n^2 n^10 10^n

N is an integer between 0 and 9. For how many values of N does [123,3N2] = [0] mod 8, where 123,3N2 is a six-digit number?

123,312 mod 8 = 0 123,322 mod 8 = 2 etc. answer is 3

What is the sequence of remainders obtained when using Euclid's algorithm to compute the greatest common divisor (GCD) of 178 and 20? A. 18, 2, 0 B. 8, 2, 0 C. 8, 4, 2, 1, 0 D. 18, 4, 2, 1, 0

178 = 20(8) + 18 20 = 18(2) + 2 8 = 4(2)+0 A.

log(n): Logarithmic

2nd fastest behind constant time O(1) Ignore log bases: O(log10(n)) = O(log2(n)) = O(log(n)) Same growth as O(log(n^k )) = O(k log(n)) = O(log(n))

How do we do summation questions on calc?

2nd-> Catalog -> Summation

A mother, father, and their 3 children are having their picture taken. They will all be seated elbow-to-elbow on the living room couch, and the children will not be permitted to sit next to each other. How many different arrangements are possible for the picture?

3! for children 2! for parents 3!*2! = 12

What is the ones digit of the number 3^902 ?

3^1 = 3 3^2 = 9 3^3 = 27 3^4 = 81 3^5 = 243 - same as 3^1, last digit 3 4 units 902/4 = 225(4) + 2 Take the 2 and go to second position 3^2 = 9 answer is 9

log^c(n): Polylogarithmic

3rd fastest Don't forget that: log^c x = (log x)^c

In the inductive proof of: 4+9+14+19+...+(5n+4)=n2(3+5n)4+9+14+19+...+(5n+4)=n2(3+5n) The inductive hypothesis is that for any n = k, 4+9+14+19+...+(5k+4)=k2(3+5k)4+9+14+19+...+(5k+4)=k2(3+5k) What must be proven assuming the inductive hypothesis is true? 4+9+14+19+...+(5k+5)=k+12(3+5(k+1)) 4+9+14+19+...+(5k+4)+5(k+4)=k+12(3+5(k+1)) 4+9+14+19+...+(5k+4)+(5(k+4)+1))=k2(3+5k) 4+9+14+19+...+(5k+4)+(5(k+1)+4)=k+12(3+5(k+1))

4+9+14+19+...+(5k+4)+(5(k+1)+4)=k+12(3+5(k+1)) always +1 to all of the k's on the right side

Section 4.18 How many numbers in the range from 1 through 42 are divisible by 2, 3, or 7?

42/2 numbers are divisible by 2. 42/3 numbers are divisible by 3, and 42/7 numbers are divisible by 7. 42/(2 · 3) = 7 numbers are divisible by 2 and 3. 42/(2 · 7) = 3 numbers are divisible by 2 and 7. 42/(3 · 7) = 2 numbers are divisible by 3 and 7.42/(2 · 3 · 7) = 1 number is divisible by 2, 3, and 7.21 + 14 + 6 - 7 - 3 - 2 + 1 = 30

How many ways can we add three non-negative integers such that they sum to 9?

55

Let N = 1^2 = 2^2 + 2^3. Given that M^2 ≡ 51 (mod 59), what is M^12 (mod 59)?

7 𝑀^2≡51(mod59)⟹𝑀^2≡−8(mod59) 𝑀^4≡64(mod59)⟹𝑀^4≡5(mod59) 𝑀^8≡25(mod59)⟹𝑀^12≡5(25)(mod59) 𝑀^12≡125(mod59)⟹𝑀^12≡7(mod59)

Given N = 1829 and e = 859 find the ciphertext for N = 78

78^859 % 1829 = 498

A random experiment consists of tossing a fair six-sided die repeatedly.How many tosses are required to be certain that the probability that at least one '6' appears is greater than or equal to 1/2? 3 4 5 6

As with many problems like this, you must reverse the problem slightly. In order to find the probability that you will get a 6 at least once, you must first find the probability that you will NOT get a 6 any of those times. This is much easier. Say p = probability of getting a 6 on each throw = 1/6. p' = probability of NOT getting a 6 on each throw is 1-p = 5/6. When you want to compute the probability of multiple (independent) events happening, you must multiply their individual probabilities (not add them). So The probability of not getting a 6 n times = p' to the nth power. In this case (5/6) ^6 = 0.334 rounds up to 4

Which Algo uses 2 for loops and floats the largest number to the right?

Bubble Sort

Section 5.9 Dice is rolled twice What is the probability that exactly one of the two rolls comes up 6?

Either the first roll is 6 and the second is not 6, or the first roll is not 6 and the second is 6. The two possibilities are mutually exclusive and each has a probability of 10/49. Therefore the probability that exactly one roll comes up 6 is 10/49 + 10/49 = 20/49.

Section 4.18 Erica goes swimming three out of the seven days of the week. How many possibilities are there for her swim schedule if she goes swimming on Monday or Tuesday or both? (Define M to be the set of schedules in which Erica goes swimming on Monday. Let T be the set of schedules in which Erica goes swimming on Tuesday.)

If Erica swims Monday, there are 6 remaining days from which to select the other two days that she swims, so |M|=(62)=15. Similarly, |T|=(62)=15. If she goes swimming Monday and Tuesday, there are five days from which to select her third swimming day, so |M∩T|=(51)=5. The number of schedules in which she goes on Monday or Tuesday (or both) is|M ∪ T| = |M| + |T| - |M ∩ T| = 15 + 15 - 5 = 25.

What are the last 4 bits in the binary representation of 3^1402

If we want to know the last 4 bits of the binary representation, we really just want to know what the number is mod 16. First we have to find the binary representation of 1402 in order to do the successive squaring method.

Which algo uses divide and conquer and can be done recursively?

Merge Sort

What kind of questions is this and what formula do we use? How many ways are there to place 6 identical objects into 3 different bins?

Multiset Counting (n+m-1) m-1 found on formula page

A grocery store stocks 1-gallon cartons of skim milk, 1% milk, 2% milk, and whole milk. A customer is asked to buy 10 gallons of milk. The customer needs to buy at least one carton of each type of milk. How many different ways can the kinds of milk to buy be selected?

Multiset formula (n+m-1 C m-1) 6+4-1 C 4-1 (9 C 3) = 84

Exponential

O(2^n) or O(n!)

Heap Sort Runtime and Space?

O(N) : worst - O(n log(n)) Ω(N): best -O(n log(n)) Θ(N): average -O(n log(n)) Space -O(1)

Heap Sort Runtime and Space?

O(N) : worst - O(n log(n)) Ω(N): best -O(n log(n)) Θ(N): average -O(n log(n)) Space -O(n)

Merge Sort Time and Space?

O(N) : worst - O(n log(n)) Ω(N): best -O(n log(n)) Θ(N): average -O(n log(n)) Space -O(n)

Quick Sort time and space?

O(N) : worst - O(n^2) Ω(N): best -O(n log(n)) Θ(N): average -O(n log(n)) Space -O(n)

Bubble Sort Time and Space Complexity?

O(N) : worst - O(n^2) Ω(N): best -O(n) Θ(N): average -O(n^2) Space -O(1)

Insertion Sort Time and Space Complexity?

O(N) : worst - O(n^2) Ω(N): best -O(n) Θ(N): average -O(n^2) Space -O(1)

Runtime and Space of Selection Sort?

O(N) : worst - O(n^2) Ω(N): best -O(n^2) Θ(N): average -O(n^2) Space -O(1)

Linear

O(n) 4th fasest

Using the provided pseudo-code, find the worst case performance in Big-O notation. procedure a=1c=0 while a < n do for i = 0; i < n; i++ do c=c+1 a=a*3

O(nlogn) The index, a, in the while loop is multiplied by 3 each iteration causing it to run about log3 n iterations. The for loop iterates n times for each iteration of the while loop. With the nested loops, we multiply to get O(n log n)

A life insurance company issues standard or preferred policies. Of the company's policyholders, 60% have standard policies and a probability of 0.01 of dying in the next year, and 40% have preferred policies and a probability of 0.08 of dying in the next year. A policyholder dies in the next year. What is the conditional probability of the deceased having a preferred policy? P(S) = 0.60, P(P) = 0.40,P(D|P) = 0.08, P(D|S) = 0.01, and the answer is 0.8421. P(S) = 0.60, P(P) = 0.40, P(D|P) = 0.01, P(D|S) = 0.08, and the answer is 0.6154. P(S) = 0.40, P(P) = 0.60, P(D|P) = 0.08, P(D|S) = 0.01, and the answer is 0.9231. P(S) = 0.40, P(P) = 0.60, P(D|P) = 0.01, P(D|S) = 0.08, and the answer is 0.1579.

P(S) = 0.60, P(P) = 0.40,P(D|P) = 0.08, P(D|S) = 0.01, and the answer is 0.8421. Here is a way(not the most mathematical perhaps) to think of it if it confuses you: You have 1000 people. 600 of them have standard policy. 400 have preferred policy. The ones that are going to die next year are 600*0.01 from the ones with standard policy and 400*0.08 from the ones with preferred policy. So a total of 600∗0.01+400∗0.08600∗0.01+400∗0.08 people are going to die next year. So given that someone died, the probability of him/her being from the ones with preferred policy is 400∗0.08600∗0.01+400∗0.08400∗0.08600∗0.01+400∗0.08 That is what the Bayes Theorem actually says here. https://math.stackexchange.com/questions/3265884/how-to-use-bayes-theorem-to-solve-following-problem

Which algo has a pivot and is recursive?

Quick Sort

A drawer has 7 socks. 4 socks are black and 3 are white socks. John randomly pulls out 4 socks. Find the probability of the following: At most 2 are black.

Section 5

Which algo updates a minimum index?

Selection Sort

What is the minimum number of bits required for the binary representation of a number greater than 32? 4 5 6 10

Since 2^5 is 32 anything bigger would be 6 2 because it says binary

For all natural numbers n, the following equality holds: 11 + 19 + 27 + · · · + (8n + 3) = n(4n + 7). What is the base case? What is the induction hypothesis? What needs to be proved to complete the induction step?

Solution: BaseCase: n=1,11=1(4(1)+7) Inductive Hypothesis: Assume 11 + 19 + 27 + · · · + (8k + 3) = k(4k + 7) for positive integer k. Need to Prove: Show11+19+27+···+(8k+3)+(8(k+1)+3)=(k+1)(4(k+1)+7).

Susan must do exactly 100 push ups in the course of a seven day week. How many different schedules are there for her to do her push ups if she must do at least 20 on each weekend day (Saturday and Sunday)? A schedule consists of the number of push ups she does on each of the seven days of the week, for example, Mon: 15, Tue: 0, Wed: 15, Thu: 15, Fri: 5, Sat: 25, Sun: 25.

Solution: 90,858,768 Start by giving both Saturday and Sunday 20 push ups. These days could get more so they are still included in the next step.We now count how many ways there are to distribute the remaining 60 push ups over the seven days. This is a multiset with n = 60 and m = 7.

A coin is flipped 20 times and the results are recorded. How many outcomes have exactly 9 heads?

Solution: C(20,9)=167,960

Twenty coins are flipped. How many outcomes have at least 4 heads facing up?

The quickest approach is to use the complement rule as described in Lesson 4.12: If S is the set of all outcomes and P ⊆ S, then |P| = |S| − |P|. We use P = set of outcomes with at least 4 heads. Then P = set of outcomes with less than 4 heads, which is easier to think about as zero, one, two, or three heads. So we end up with |P | = |no heads| + |one head| + |two heads| + |three heads| 20 20 20 20 =0+1+2+3 = 1 + 20 + 190 + 1140 = 1351 |P|=|S|−|P|=2^20 −1351=1,047,225

Suppose an+1 = 3an - 2an-1 and a0 = 1, a1 = 2. What is an expressed as a function of n? 2^n n+1 (-1)n + 3n (-2)n + 4n

This is a recurrence relation question, notice they ask for the value of an not the whole equation, when we work through this we see an = 2^n

There are two coins, one fair and one biased. The biased coin comes up heads with a probability 0.8 and tails with a probability 0.2. One of the coins is selected at random and flipped ten times. The results of the coin flips are mutually independent. The result of the 10 flips is H, T, T, H, H, T, H, H, T, H. What is the probability that the coin flipped was the biased coin? (Round to the nearest tenth.) .3 .4 .2 .5

Use Bayes Theorem (.2)(.5)/(.4) = .25 round to 0.3

There are 250 pieces of candy in a jar and each one has a color, either red, orange, yellow, green, blue, or purple. The jar contains 37 red, 48 blue, and 55 yellow. How many pieces of candy are either blue, green, purple, or orange?

We can use the complement rule described in 4.12: If S is the set of all outcomes and P ⊆ S, then |P | = |S| − |P |. Let P be the set of blue, green, purple, or orange candy.|blue, green, purple, or orange| = |total| - |NOT(blue, green, purple, or orange)| = |total| - |red or yellow| = 250 - (37 + 55) = 158

An encryption scheme uses the numerical position of a letter in the alphabet to encrypt characters, e.g., A=1, D=4, Z=26, etc., and spaces are ignored. What is the encoding of "HAPPY BIRTHDAY" using this technique? A. 81662529182084125 B. 81662529082084125 C. 8116162529082084125 D. 8116162529182084125

Work RIGHT to LEFT

How many cards must be drawn from a standard deck of 52 playing cards to guarantee: a. at least two have the same suite? b. at least 5 have the same suit?

a. Solution: 5 By the pigeonhole principle (Lesson 4.20), we need one more card than total number of suits. b. Solution: 17 This time, use the "Contrapositive of the generalized pigeonhole principle" in Lesson 4.20 where k = 4 (the four suits), and b = 5 (at least five of the same suit). So n must be at least 4(5−1)+1 = 17. That is we need at least 17 cards to guarantee 5 have the same suit.

For the recurrence relation, dn = −dn−1 + 6dn−2, answer the following questions. a. What is the characteristic equation? b. What are the roots of the characteristic equation? c. If d0 = 1 and d1 = 4, find the closed form expression for dn. (Solve the recurrence relation.) d. What is d10? What is d14?

d0 = 1, d1 = 4 a. dn = x^2, -dn-1 = -x, 6dn-2 = 6 x^2 = -x + 6 = x^2 + x -6 b. (x + 3)(x - 2) = x =-3, 2 c. 1 = C1 + C2 4 = C1(2) + C2(-3) take 1 = C1 + C2 and multiply it by -2 so we can cancel out C1 4 = C1(2) + C2(-3) + -2 = C1(-2) * C2(-2) -------------------- 2 = C2(-5) C2 = 2/-5 plug C2 back into = 1 1 = C1 -2/5 c1 = 7/5 dn = 7/5 (2) ^n + 2/-5(-3)^n

An ordered binary tree is also known as?

heap max heap is when parent > child

Which sort algo uses a binary tree?

heap sort

Consider the equation a+b+c+d=12. We're looking for the number of solutions this equation has

https://brilliant.org/wiki/integer-equations-star-and-bars/ 15 C 3

Which algo works left to right and swaps the i item with the appropriate items to its left until its in the right spot?

insertion sort

Section 4.20 How many cards must be drawn from a standard deck of 52 playing cards to guarantee at least 5 have the same suit?

k(b - 1) + 1 Solution: 17 This time, use the "Contrapositive of the generalized pigeonhole principle" in Lesson 4.20 where k = 4 (the four suits), and b = 5 (at least five of the same suit). So n must be at least 4(5−1)+1 = 17. That is we need at least 17 cards to guarantee 5 have the same suit.

Quadratic

n^2 n^2 log(n)

Polynomial

n^3

Linearithmic/Loglinear

nlog(n)


Set pelajaran terkait

Vocabulary Workshop Level E Unit 13 Answers

View Set

Foundations and Practice of Mental Health Nursing HESI EXIT 5

View Set

server 2008 infrastructure chp 5

View Set

Macroeconomics Chapter 18 True/False

View Set