Discrete Mathematics II Study Cards

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Cryptographers will use the name "Alice" to reference the sender, the name "Bob" to reference the receiver, and the name __________ to reference the eavesdropper.

"Eve"

What is the decimal expansion of (10)_17?

(1 * 17^1) + (0 * 17^0) = 17

What is the decimal expansion of (10011)_2?

(1 * 2^4) + (0 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0) = 16 + 0 + 0 + 2 + 1 = 19

What is the decimal expansion of (116)_7?

(1 * 7^2) + (1 * 7^1) + (6 * 7^0) = 49 + 7 + 6 = 62

What is the decimal expansion of (410)_5

(4 * 5^2) + (1 * 5^1) + (0 * 5^0) = 105

What is the binary representation of 13?

1101

What is the value of (6 + 8) mod 4?

2

Find the expansion base 5 of 57

212 57 mod 5 = 2; Rightmost digit is 2 57 div 5 is 11 11 mod 5 = 1; Next digit to the left is 1. 11 div 5 = 2 2 mod 5 = 2; Next digit to the left is 2 2 div 5 = 0 Done!

Euclid's algorithm returnsgcd(61, 54) = 1 = 26 · 54 - 23 · 61 What is the multiplicative inverse of 54 mod 61?

26 26 is the coefficient of 54 in the equation 1 = 26 * 54 - 23 * 61 The inverse of 54 mod 61 is (c mod 61), where c is the coefficient of 54: 26 mod 61 = 26

If the prime factorizations for 147, 315, and 550 are given below, what is gcd(147, 315)? 147 = 3 * 7^2 315 = 3^2 * 5 * 7 550 = 2 * 5^2 * 11

3 * 5^0 * 7 = 3 * 7 = 21

What is the prime factorization for 31? 31 1 * 31 3 * 13

31 31 is a prime number, so its prime factorization is itself

If the prime factorizations for 147, 315, and 550 are given below, what is lcm(147, 315)? 147 = 3 * 7^2 315 = 3^2 * 5 * 7 550 = 2 * 5^2 * 11

3^2 * 5 * 7^2

23 div 5

4

17 mod 6

5

-13 mod 6

5 Starting with -13, when 6 is added three 3 to -13, the result is 5, which is in the range from 0 through 5.-13 + 3 · 6 = 5-13 = -3 · 6 + 5

Multiplicative inverse mod n

A multiplicative inverse mod n (or just inverse mod n) of an integer x, is an integer s ∈ {1, 2, ..., n-1} such that sx mod n = 1. Alternatively, we could say that s is the multiplicative inverse of x in Zn.

Below is an example of a hexadecimal expansion of a number and its corresponding decimal representation. Note that A represents the value 10 and B represents the value 11:

A3B = 10 * 16^2 + 3 * 16^2 + 11 * 16^0 = 2619

Rule of thumb for asymptotic notation:

Simple programs can be analyzed by counting the nested loops of the program. - A single loop over n items yields asymptotic complexity n. - A loop within a loop yields n^2. - A loop within a loop within a loop yields n^3. Given a series of for-loops that are sequential, the slowest of them determines the asymptotic behavior of the program. Two nested loops followed by a single loop is asymptotically the same as the nested loops alone, because the nested loops dominate the simple loop.

Theorem: For all n ∈ Z+, Q(n) is true, where Q(n) is a statement that is parameterized by a positive integer n. In an inductive proof of the theorem, what must be proven in the base case? Q(0) is true Q(1) is true Q(k) is true Q(n) is true

The first positive integer is n = 1, so the base case shows that Q(n) is true for n = 1 Q(1) is true

What would be the gcd of 924 = 2^2 * 3^1 * 5^0 * 7^1 * 11^1 33075 = 2^0 * 3^3 * 5^2 * 7^2 * 11^0

The gcd is obtained by taking the smaller of the exponents of each prime from 924 and 33075, which results in gcd(924, 33075) = 2^0 * 3^1 * 5^0 * 7^1 * 11^0 This comes out to be 25

Infinite number of primes

There are in infinite number of primes This theorem was proven by the Greek mathematician Euclid around 300 B.C.

A Θ(n) algorithm is O(n)

True

Let x and y be two integers. Then x divides y (denoted x|y) if there is an integer k such that y = kx. "x does not divide y" is denoted by x ∤ y. If x divides y, then y is said to be a multiple of x, and x is a ____________________________ of y.

factor or divisor

Go back and do **3.7.1 problems

just to make sure you have it down for the test! These are fun!

Alice sends the ciphertext c to Bob. When Bob receives the ciphertext c, he decrypts c as follows:

m = (c - k) mod N (decryption)

Suppose you wanted to compute xy, for positive integers x and y. Computing exponents is, in fact, an important step in the RSA cryptosystem discussed later. One way to go about the computation is to start with some variable p initialized to x. Then multiply p times x a total of y - 1 times. This method for computing xy requires y-1 multiplication operations which could take an impractical amount of time if y is a very large number. Suppose instead, we start with p initialized to x and keep squaring p. If the value of p is currently x^a for some integer a and p is squared, then its exponent goes up by a factor of 2:

p^2 = (x^a)^2 = x^(2a) If squaring is done repeatedly, then the exponent gets large must faster but it is always a power of two

Some sequences are most naturally defined by specifying one or more initial terms and then giving a rule for determining subsequent terms from earlier terms in the sequence. A rule that defines a term an as a function of previous terms in the sequence is called a _____________________________. For example, in an arithmetic sequence, each number is obtained by adding a fixed value to the previous number.

recurrence relation

brute force algorithm

solves a problem by exhaustively searching all possible solutions without using an understanding of the mathematical structure in the problem to eliminate steps

The simple encryption scheme presented here is an example of symmetric key cryptography. In a _________________________________, Alice and Bob must meet in advance (or communicate over a reliably secure channel) to decide on the value of a shared secret key.

symmetric key cryptosystem

asymptotic complexity

the behavior of the complexity function as n grows. In the next lesson you will learn how to use a specific asymptotic notation, big-O, to analyze the asymptotic complexity of an algorithm.

Decrypt

the process of transforming data that has been rendered unreadable through encryption back to its unencrypted form

Encrypt

the process of transforming information or data into a code to prevent unauthorized access

Pseudocode

uses specifically formatted natural-language- like statements to capture these steps in the algorithm. The prefix "pseudo" even indicates that this code is mock code. While it would not readily execute in a computer, it helps us design a computer program or create a template that a computer developer can take and implement in any programming language.

Give a binary representation for each number given below in hex. Drop the leading zeroes in your binary representation. (b) (1FC)_16

(1)16 = (0001)2 (F)16 = (1111)2 (C)16 = (1100)2 (1FC)16 = (000111111100)2 = (111111100)2

How would you convert a number base b into its decimal expansion for (2012)_3

(2012)_3 = we do the biggest power from left to right (2 * 3^3) + (0 * 3^2) + (1 * 3^1) + (2 * 3^0) = 54 + 0 + 3 + 2 = 59

Give a binary representation for each number given below in hex. Drop the leading zeroes in your binary representation. (a) (A3)16

(A)16 = (1010)2 (3)16 = (0011)2 (A3)16 = (10100011)2

Euclid's algorithm returnsgcd(14, 33) = 1 = 3 · 33 - 7 · 14. What is the multiplicative inverse of 14 in Z33?

-7 -7 is the coefficient of 14 in the equation:1 = 3 · 33 - 7 · 14The inverse of 14 in Z33 is (c mod 33), where c is the coefficient of 14:-7 mod 33 = 26

Use a calculator for this question if needed. Consider a random integer selected from the range from 2 to 1,000,000,000,000. Approximately, what are the chances that the selected number is prime?

0.036 The chances that the selected number is prime is 1/ln(1,000,000,000,000) which is approximately 0.036

Public key cryptography

1.) Alice encrypts her message to Bob using the public key 2.) Alice sends the encrypted message to Bob. Eve cannot read the encrypted message 3.) Bob decrypts the message using his private key

Preparation of public and private keys in RSA

1.) Bob selects two large prime numbers, p and q 2.) Bob computes N = p*q and φ = (p-1)(q-1). [Note the symbol φ is read Phi.] 3.) Bob finds an integer e such that gcd(e, phi) = 1 4.) Bob computes the multiplicative inverse of e mod φ: an integer d such that (ed mod φ) = 1. 5.) Public (encryption) key: N and e 6.) Private (decryption) key: d

Use the prime number theorem to give an approximation for the number of prime numbers in the range 2 through 10,000,000.

10,000,000 = 107. The number of prime numbers in the range 2 through 107 is approximately 107/ln(107) ≈ 620421.

Suppose Bob selects prime numbers p=5 and q=11. What is φ?

40 φ=(5−1)(11−1)=40

Finding the inverse of a number mod n is a key step in the RSA cryptosystem covered layer Match each integer with it's multiplicative inverse mod 11: 10 5 7 and we have 8 mod 11 9 mod 11 10 mod 11 as possible matches...

7 * 8 mod 11 = 56 mod 11 = 1 5 * 9 mod 11 = 45 mod 11 = 1 10 * 10 mod 11 = 100 mod 11 = 1

For each x and n, find the multiplicative inverse mod n of x. Your answer should be an integer s in the range 0 through n - 1. Check your solution by verifying that sx mod n = 1. x = 52, n = 77

77 52 25 2 1 77 mod 52 = 25 52 mod 25 = 2 25 mod 2 = 1 The equations for substitution are: 1 = 25 - 12·2 2 = 52 - 2·25 25 = 77 - 52 Substitute (52 - 2·25) for 2 into the equation 1 = 25 - 12·2 1 = 25 - 12·(52 - 2·25) = 25·25 - 12·52 Substitute (77 - 52) for 25 into the equation 1 = 25·25 - 12·52 1 = 25·(77 - 52) - 12·52 = 25·77 - 37·52 gcd(77, 52) = 1 = 25·77 - 37·52 The coefficient of 52 in the equation above is -37. The multiplicative inverse of 52 mod 77 is (-37 mod 77) = 40. Check: 52·40 mod 77 = 2080 mod 77 = 1

The following is a description of a cryptosystem process:

A sender encrypts a plaintext message. An eavesdropper on the encrypted message will not be able to read the ciphertext. The receiver will read the ciphertext message after applying a secret key to decrypt the message back into plaintext.

The proof that S(n) is true for all non-negative integers n has two components:

Base case: S(0) and S(1) are true Inductive step: For every k >= 1, (S(0) ^ S(1) ^ ... ^ S(k)) implies S(k+1)

_____________________ is the science of protecting and authenticating data and communication. One important aspect of cryptography is the practice of sending messages securely in the presence of eavesdroppers who can learn the transmitted information. Cryptography is ubiquitous in the electronic age in which sensitive information such as credit card numbers and passwords are sent over the internet on a daily basis. While the advent of electronic commerce has made the use of cryptography commonplace, cryptography has been used throughout the ages, particularly in times of war.

Cryptography

Select the choice that is equivalent to the following statement: For k ≥ 7, if P(j) is true for all j in the range 2 through k, then P(k+1) is true.

For k >= 7, (P(2) ^ P(3) ^ ... P(k)) implies P(k+1)

A slightly better brute force algorithm for factoring

Input: Integer N greater than 1 Output: "Composite" if composite, else "Prime" For x= 2 to ⌊N⌋ If x evenly divides N, Return("Composite") End-for Return("Prime")

Euclid's algorithm for finding the greatest common divisor:

Input: two positive integers, x and y. Output: gcd(x, y) If ( y < x ) Swap x and y r = y mod x While (r != 0) y := x x := r r := y mod x End-while Return(x) *** you're just going to have to memorize this one so that you can write it out and compute it on the test **Do this on the board a few times

Expressing gcd(x,y) as a linear combination of x and y

Let x and y be integers, then there are integers s and t such that gcd(x, y) = sx + ty

GCD Theorem

Let x and y be two positive integers. Then gcd(x,y) = gcd(y mod x, x)

Suppose Bob selects prime numbers p=5 and q=11. What is N?

N = (5)(11) = 55

Suppose that the inductive step of a strong induction proof shows that for k ≥ 1, if (S(0) ∧ S(1) ∧ .... ∧ S(k)) is true, then S(k+1) is true. If you assume that the inductive hypothesis is true, can you conclude that S(k-2) is true?

No

ciphertext

an encrypted message

Plaintext

an unencrypted message

Key

an unpredictable (typically large and random) string of numbers to decrypt an encrypted message

Closed form for the sum of terms in an arithmetic sequence For any integer n >= 1 ∑k=0n−1 (a+kd)

an+d(n−1)n2

The binary representation of 18 is 10010. Which expression is equivalent to b^(18)?

b^2^4 * b^2^1

The representation of n base b is called the _______________________________________ and is denoted by (akak-1...a1a0)b. The following animation shows how to convert the base b expansion of a number into its decimal expansion.

base b expansion of n

Hexadecimal notation is particularly useful in computer science because each hexadecimal digit can be used to represent a 4-bit binary number. A _____________, which consists of 8 bits, can be represented by a 2-digit hexadecimal number. Two hexadecimal digits is easier for a human to recognize and remember than 8 bits. For example, 01101100 is represented by the hexadecimal number 6C, because the first 4 bits 0110 correspond to 6 and the second 4 bits 1100 correspond to C.

byte

A formal specification of the algorithm to compute xy is given below. The caption describes the algorithm as an iterative algorithm for fast exponentiation. An _____________________ algorithm uses a loop to accomplish repeated operations in contrast with a recursive algorithm which uses recursion. A recursive algorithm for fast exponentiation is presented in the material on recursive algorithms.

iterative

What is the asymptotic behavior for 5n+2?

n

How many digits are required to express the base 8 expansion of 9? ⌈log_9 ⁡9⌉ ⌈log_8 10⌉

n = 9 and b = 8 The number of digits in a base b expansion of n is [log_b(n+1) = [log_8(9 + 1)]

Largest number represented by k digits base b:

n = [b-1][b-1]...[b-1]_b = (100...0)_b - 1 = b^k - 1

The ________________________________________________ states that if the base case (for n = 1) is true and inductive step is true, then the theorem holds for all positive integers.

principle of mathematical induction

The expression ∑j=14j3 is called the _____________________ of the sum, and the expression 13 + 23 + 33 + 43 is called the _____________________ of the sum. When the expression to be summed has more than one term, it is important to use parentheses to indicate that all the terms are included in the summation as in ∑j=1n(j+1) because the expression ∑j=1nj+1 is interpreted as (∑j=1nj)+1.

summation form expanded form

algorithm complexity

which is the study of the efficacy of algorithms that gives us a framework to compare algorithms

Algorithm Fibonacci-2 is better

written in notes

Does 7 divide 56?

yes 56 = 7 * 8 56 is an integer multiple of 7

What is the value of 5 * 7 mod 9?

8

How many digits are required to express the base 7 expansion of 2401? - [log_7 2402] - [log_7 2401]

[log_7 2402] n = 2401 and b = 7 The number of digits in a base b expansion of n is ⌈logb⁡(n+1)⌉=⌈log7⁡(2401+1)⌉.

Find the expansion base 7 of 52

`03 52 mod 7 = 3; Rightmost digit is 3. 52 div 7 = 7 7 mod 7 = 0; Next digit to the left is 0. 7 div 7 = 1 1 mod 7 = 1; Next digit to the left is 1. 1 div 7 = 0 Done!

Decrypting a message using RSA

`n the previous lesson, the message "no" was encrypted into the ciphertext c=329940 using the public key N=373097 and e=459173. Use the private key d=84173 to retrieve the plaintext. Solution The formula m=cd mod N is used. m=32994084173=7879 mod 373097 Looking at the ASCII table, we note that 78 and 79 give the letters "n" and "o" respectively. Thus, the original message "no" is recovered.

Recurrence relation defining an arithmetic sequence

a_0 = a (initial value) a_n = d + a_(n-1) for n >= 1 (recurrence relation) Initial value = a. Common difference = d

Recurrence relation defining an geometric sequence

a_0 = a (initial value) a_n = r * a_(n-1) (recurrence relation) Initial value = a. Common ratio = r.

Given the set {0, 1, 2, 3, 4}, we can define addition and multiplication on the elements in this set in the usual way, except that the mod 5 function is applied afterwards to ensure that the result will again be from {0, 1, 2, 3, 4}. For example, adding 2 and 4 would result in 1 since 6 mod 5 = 1. Similarly, multiplying 3 and 4 would result in 2 since 12 mod 5 = 2. The operation defined by adding two numbers and applying modulo n to the result is called ___________________________. The operation defined by multiplying two numbers and applying modulo n to the result is called __________________________________________.

addition modulo n multiplication modulo n

No matter which programming language is used, there are three basic building blocks of an algorithm:

assignments conditional statements loops

As you may recall from the previous module, each algorithm uses assignments, conditional statements, and loops, and performs a variety of operations, such as addition and multiplication. These operations (e.g., addition, multiplication, comparison) that one would find in a single line of pseudocode, are referred to as __________________________. They are called "atomic," because they cannot be split any further; a computer would evaluate each in one step.

atomic operations

The predicate S(n) may be true only for n greater than or equal to a particular value denoted below by the constant a. Also, the base case may require proving the assertion directly for more than one value. The _____________________ for a proof by strong induction establishes that S(n) holds for n = a through b, where a and b are constants. The _______________________ in a proof by strong induction assumes that S(j) is true for all values of j in the range from a through some integer k ≥ b and then proves that theorem holds for k+1.

base case inductive step

The algorithm calculates the nth element of the Fibonacci sequence by calculating all n terms:

F[1] :=1F[2]:=1For i:=3 to nF[i] := F[i-1]+F[i- 2]End-forReturn (F[n])

A Θ(n) algorithm is O(1)

False

Give a binary representation for each number given below in hex. Drop the leading zeroes in your binary representation. (c) (2A0B)_16

(2)16 = (0010)2 (A)16 = (1010)2 (0)16 = (0000)2 (B)16 = (1011)2 (2A0B)16 = (0010101000001011)2 = (10101000001011)2

****make sure to go back and write out all of the proofs

*** These will really be good to know before the test

-13 div 6

-3 Starting with -13, 6 is added 3 times until the result yields a number in the range from 0 through 5.-13 + 3 · 6 = 5-13 = -3 · 6 + 5

-10 mod 5

0

What is the value of 4 * 9 mod 6?

0

[(73 mod 10) + (37 mod 10)] mod 10

0

The algorithm below multiplies the values of two variables, A and B, and assigns the product to the variable C. C: = A × B Regardless of what the size of the input might be, this algorithm always runs a constant number of operations, so its asymptotic complexity is ______.

1

What is the asymptotic behavior of 109?

1

Find the binary of 21

10101 21 mod 2 = 1; Rightmost bit is 1.21 div 2 = 1010 mod 2 = 0; Next bit to the left is 0.10 div 2 = 55 mod 2 = 1; Next bit to the left is 1.5 div 2 = 22 mod 2 = 0; Next bit to the left is 0.2 div 2 = 11 mod 2 = 1; Next bit to the left is 1.1.1 div 2 = 0Done!

What is the binary expansion of (2F)_16? Omit the leading zeroes in your answer

101111 0010 corresponds to 2 and 1111 corresponds to F. Put 0010 and 1111 together to get 00101111 and drop the leading zeroes to get 101111.

If we have 0, 60, 25, 17, which numbers would need to match in order to achieve congruent modulo 11? 88 5 -8 39

11 evenly divides 88 - 0 = 88 11 evenly divides 5 - 60 = -55 11 evenly divides -8 - 25 = -33 11 evenly divides 39 - 17 = 22

If the prime factorizations for 147, 315, and 550 are given below, what is lcm (315, 550)? 147 = 3 * 7^2 315 = 3^2 * 5 * 7 550 = 2 * 5^2 * 11

2 * 3^2 * 5^2 * 7 * 11

In which prime factorization are the prime factors listed in non-decreasing order? 2 * 7 * 13 * 11 2 * 7 * 11 * 13 7 * 2 * 11 * 13

2 * 7 * 11 * 13

If the prime factorizations for 147, 315, and 550 are given below, what is gcd(315, 550)? 147 = 3 * 7^2 315 = 3^2 * 5 * 7 550 = 2 * 5^2 * 11

2^(0,1) * 3(0,2) * 5^(1,2) * 7^(0,1) * 11^(0,1) = 5

Which of the following is the prime factorization for 48? 3 * 4^2 2^4 * 3 2 * 3^2

2^4 * 3 = 48. Also, 2 and 3 are both prime numbers

For each value of y, express by as a product of terms of the form b2j, where j is a non-negative integer. (a) y = 53

53 = (110101)2 53 = 2^5 + 2^4 + 2^2 + 2^0 b^53 = b^2^5 · b^2^4 · b^2^2 · b^2^0

What is the hexadecimal number that corresponds to 1011101?

5D The rightmost four bits, 1101, corresponds to D. The remaining bits on the left are 101. Add a leading zero to 101 on the left to get 0101 which corresponds to 5. Therefore 1011101 corresponds to a hexadecimal expansion of 5D.

If 7 = 2^2 + 2^1 + 2^0 Which expression is equivalent to 5^7? 5^2^2⋅5^2^0 5^2^2⋅5^2^1⋅5^2^0 5^2^3⋅5^2^2⋅5^2^0

5^2^2⋅5^2^1⋅5^2^0

[(27 mod 7 )(64 mod 7)] mod 7

6

(651^(23) + 17) mod 10

651 mod 10 = 1 Therefore, (651^23 + 17) mod 10 = (1^23 + 17) mod 10 = (1 + 17) mod 10 = 8

Suppose that the slightly better brute force algorithm for factoring is given the number 653117 as input. How many numbers would the algorithm have to check to either find a factor or determine that the input is prime? (653117 happens to be a prime number).

808 The algorithm can stop checking numbers when it reaches x = x=⌊653117⌋=808. Since 653117 is prime, the algorithm will not find a factor before reaching x = 808

What is the decimal expansion of (2F)_16?

= 2 * 16^1 + 15 * 16^0 = 47

The description of an algorithm usually includes:

A name for the algorithm A brief description of the task performed by the algorithm A description of the input A description of the output A sequence of steps to follow

The initial terms of the sequence are often notated a0 or a1. In this course, the initial term is denoted a0. In the previous example there was one initial term a0=7. However, recursion equations can have as many initial values as the relation defines. For example, let an=an-1+an-2+an-3 for n ≥ 4 with initial values a0=1, a1=1, and a2=4. The number of initial terms used by an equation will be equal to the number of previous terms present in the equation. For example, an=2×an-1+an-2 requires 2 initial terms.

A recursion relation needs to be written as a general equation (one that works for all values of n). Because the recursion builds on itself, you must tell the equation where to start and define the rule to get a new term using only the previous term. For this sequence, the initial term is a0=7. The previous terms used by a recurrence relation must be included in the equation. Using the sequence of {7, 10, 13, 16, 19, 22, 25, ...} you can easily see that the pattern is to add 3 to the previous term (an-1), so the equation is an=an-1+3. Now we can define the recursion relation as: for n > 0 a_n = { 7 if n = 0 and a_(n-1) + 3 if n >3 }

Alice's message to Bob is 2317. The secret key is 2191, and N = 3391. Alice encrypts the message: C=(2317+2191) mod 3391=1117.

Alice sends 1117 to Bob who decrypts the message: m=(1117−2191) mod 3391=2317.

Why is this important for computer science? The computer uses a base 2, not a base 10 number system. As you probably know, a computer at its most basic, almost microscopic, level is just a series of electrical on/off switches. And on/off is the language of binary. That is, binary has only two digits, one (on) and zero (off), so it is a base 2 system.

As a quick example of a binary number, let's examine 10012 . Working from left to right, the first digit has a place value of 23 , next is 22 , 21 , then 20 . So the actual decimal value of the binary number 10112 is 1 x 23 + 0 x 22 + 0 x 21 + 1 x 20 = 1 x 8 + 0 x 4 + 0 x 2 + 1 x 1 = 910 . This may be a little confusing right now, but do not worry. In this lesson you will learn to understand binary numbers in terms of our everyday numbers (decimal numbers).

Suppose that cans of juice come in packs of 3 or 4. We would like to be able to buy n cans of juice by purchasing a combination of 3-packs or 4-packs. For which values of n is this possible? Let P(n) be the assertion that it is possible to buy n cans of juice by purchasing only 3-packs or 4-packs. P(7) is true because we can purchase one 3-pack and one 4-pack. P(5) is not true because there is no way to combine 3-packs and 4-packs to get five cans of juice. We will use strong induction to prove that for any n ≥ 6, P(n) is true. Here is an outline of the proof:

Base case: Prove P(6), P(7), and P(8) directly. Inductive step: For k ≥ 8, assume that that P(j) is true for any j in the range 6 through k, and prove that P(k + 1) is true.Argue that P(k - 2) is true by showing that k - 2 falls in the range 6 through k, covered in the inductive hypothesis. The argument uses the fact that k ≥ 8 and therefore k - 2 ≥ 6.Since P(k - 2) is true, k-2 cans of juice can be bought by combining 3-packs and 4-packs. By adding one 3-pack to the k - 2 cans of juice, there will be k - 2 + 3 = k + 1 cans of juice. Therefore P(k + 1) is true.

Group the numbers from the given set into classes of congruence. That is, put two numbers in the same group if they are equivalent modulo 13. {−63, -54, -41, 11, 13, 76, 80, 130, 132, 137}

Congruent to 0 modulo 13: 13, 130 Congruent to 2 modulo 13: -63, 80, 132 Congruent to 7 modulo 13: 137 Congruent to 11 modulo 13: -54, -41, 11, 76

Explicit formula for a sequence defined by a recurrence relation

Define the sequence {h_n} as: h_0 = 7 h_n = (h_(n-1))^3, for any n >= 1 Then for any n >= 0, h_n = 7^(2^n)

If x does not divide y, then there is a non-zero remainder when x is divided into y. The following theorem, called the ________________________________, states that the result of the division (the quotient) and the remainder are unique. The Division Algorithm, as stated below, is not really an algorithm at all but a statement of a mathematical fact. A procedural version that shows how to compute the quotient and the remainder is given further on.

Division Algorithm

The Fundamental Theorem of Arithmetic

Every positive integer other than 1 can be expressed uniquely as a product of prime numbers where the prime factors are written in non-decreasing order

A O(n) algorithm is Θ(1)

False This may or may not be true depending on the algorithm. In the general case it is false. If an algorithm is Θ(1), then it certainly is O(n). But if it is O(n) then it may not be Θ(1). For example, a Θ(n) algorithm is O(n) but not Θ(1).

Leonardo Fibonacci, a prominent mathematician in the middle ages, used a recurrence relation to define a sequence that is now known as the __________________________________. Fibonacci defined the sequence in an attempt to mathematically describe the population growth of rabbits. The colony starts with one pair of newborn rabbits. The rabbits must be at least one month old before they can reproduce. Every pair of reproducing rabbits gives birth to a new pair of rabbits, one male and one female over the course of a month.

Fibonacci sequence

Number representation

Fix an integer b > 1. Every non-negative integer n can be expressed uniquely as: n = a_k * b^k + a_(k-1) * b^(k-1) + ... + a_1 + b^1 + a_0 * b^0 where k is a non-negative integer, each a_i is an integer in the range from 0 to b-1, and a_k != 0

Theorem: For all n ∈ Z+, Q(n) is true,where Q(n) is a statement that is parameterized by a positive integer n. In an inductive proof of the theorem, what must be proven in the inductive step? For all positive integers k, Q(k-1) implies Q(k) For all positive integers k, Q(k) implies Q(n) For all positive integers k, Q(k) implies Q(k+1) For all positive integers k, Q(k)

For all positive integers k, Q(k) implies Q(k+1)

The digits in base b range from 0 through b - 1. The largest number that can be represented with k digits in a base b expansion is the number whose digits are all b - 1. The next highest number is the number represented by 1 followed by k 0's.

For example, if the base b = 5, the highest valued digit is 4. The largest number that can be represented with 3 digits base 5 is (444)5 which is one less than (1000)5. The value of (1000)5 is 53.

Suppose that the inductive step of a strong induction proof shows that for k ≥ 1, if (S(0) ∧ S(1) ∧ .... ∧ S(k)) is true, then S(k+1) is true. 1) What statement is equivalent to the inductive hypothesis? For k ≥ 1 and any j in the range from 0 through k, S(j) is true. For k ≥ 1 and any j in the range from 0 through k+1, S(j) is true. S(j) is true.

For k >= 2 an any j in the range from 0 through k, S(j) is true

**** Please go back and do 2.24.1 and 2.24.3 Decrypting ciphertext using RSA

Given the public key N=1829 and e=859 and the private key d=79, match each plaintext with the corresponding ciphertext

Because 16, the base of hexadecimal notation, is an integer power of 2, the base of binary expansions, there is an easy way to translate between the binary expansion and the hexadecimal expansion of a number. Each group of 4 consecutive bits can be grouped together and translated directly into a hexadecimal digit according to the table above.

Groups of four bits are used because 16 = 24. The grouping begins at the rightmost bit. If the number of bits is not a multiple of 4, then leading zeroes can be added so that the leftmost group has four bits. The process is illustrated in the figure below showing that (11101010111101000)_2 = (1D5E8)_16.

An if-statement can also be followed by a sequence of indented operations with a final end-if statement. In the block of code below, all n operations would be executed if the condition evaluates to true. If the condition evaluates to false, then the algorithm proceeds with the next instruction after the end-if.

If ( condition ) Step 1 Step 2 . . . Step n End-if

In the case that N is prime, the number of candidate factors tested will be N - 2. For the 110 digit number N given above, the number of candidate factors tested will be around 10110. Notice that the value of N is much, much larger than the number of digits in N. Even it were possible to test if a number x divides N in a nanosecond, the process would not finish in our lifetimes. The procedure can be shortened using the fact that there is no need to test factors past sqrt(N) due to the theorem below: Small Factors

If N is a composite number, then N has a factor greater than 1 and at most sqrt(N)

The Extended Euclidean Algorithm can be used to find the multiplicative inverse of x mod n when it exists.

If gcd(x, n) ≠ 1, then x does not have a multiplicative inverse mod n. If x and n are relatively prime, then the Extended Euclidean Algorithm finds integers s and t such that 1 = sx + tn. sx - 1 = -tn. Therefore, (sx mod n) = (1 mod n) = 1. It was shown earlier that if A - B is a multiple of n then (A mod n) = (B mod n). (s mod n) is the unique multiplicative inverse of x in {0, 1, ..., n - 1}.

Simple Encryption scheme requirements

If m ≠ m' and m, m' ∈ Z_N then (m + k) mod N ≠ (m' + k) mod N (no two distinct plaintexts map to same ciphertext) If m ∈ Z_N then (((m + k) mod N)-k) mod N = m (decryption scheme is inverse of encryption scheme)

For example, 3 is an inverse of 7 mod 10 because 3 · 7 mod 10 = 1. The number 7 is an inverse of 5 mod 17 because 7 · 5 mod 17 = 1. It is possible for a number to be its own multiplicative inverse mod n. For example, 7 is the inverse of 7 mod 8 because 7 · 7 mod 8 = 1.

In Z14 the multiplicative inverse of 3 is 5, because 3*5 = 1 in Z14. Not every number has an inverse mod n. For example, 4 does not have an inverse mod 6. The condition is that x has an inverse mod n if and only if x and n are relatively prime.

Big-O is the notation used to state that a function is the upper bound for the asymptotic complexity, while big-Omega is used for a lower bound.

In other terms, when an algorithm is said to be O(f(n)), then its asymptotic complexity never surpasses f(n), and when an algorithm is Ω(g(n)) then its complexity is never smaller than g(n).

In the summation ∑k=snak, the variable k is called the index of the summation. The variable s is the lower limit and the variable n is the upper limit of the summation. When the index starts at 1, the summation Sn=Σk=1nak is referred to as the nth partial sum. Since Sn=a1+a2+...+an−1+an, the nth term of a sequence can be defined recursively in terms of partial sums an=Sn−Sn−1.

In the summation ∑k=snak, the variable k is called the index of the summation. The variable s is the lower limit and the variable n is the upper limit of the summation. When the index starts at 1, the summation Sn=Σk=1nak is referred to as the nth partial sum. Since Sn=a1+a2+...+an−1+an, the nth term of a sequence can be defined recursively in terms of partial sums an=Sn−Sn−1.

Once again computer scientists are concerned with making the processing of an algorithm as efficient (fast) as possible. If exponentiation is part of the algorithm's process, having the ability to exponentiate number values quickly is vital. In a normal exponentiation process, the result is calculated by repeated multiplication. For example, 25 would be calculated by 2 x 2 x 2 x 2 x 2 = 32. For large bases and exponents this process can be extremely lengthy and time consuming.

In this lesson you will learn a more efficient method of exponentiation referred to as fast exponentiation, which is based on binary expansions of the exponent. Why is this method so much faster? Fast exponentiation uses successive squaring of values rather than repeated multiplication, which greatly speeds up the calculation process.

Now that you have read the module introduction you should be excited to learn how to use modular arithmetic. Similar to linear arithmetic, modular arithmetic has division, addition, multiplication, and subtraction operations. The good news is that modular arithmetic only uses integers-no fractional or decimal values.

In this lesson you will start with a refresher on integer division, then you will learn how to calculate problems using modular division.

Primality Testing

Input: Integer N greater than 1 Output: "Prime" if N is prime and "Composite" if N is composite

Factoring

Input: Integer N greater than 1 Output: "Prime" if N is prime. If N is composite, return two integers greater than 1 whose product is N

Brute force algorithm for factoring

Input: Integer N greater than 1. Output: "Prime" if N is prime, else "Composite" if N is composite. For x = 2 to N-1 If x evenly divides N, Return( "Composite" ) End-for Return( "Prime" )

This is literally just training for grad school, so make sure to get it right!

It's really fun because it is priming you for everything you need to know to be successful there. Treat it as training.

The loop executes 4 times on input y = 13. Which best describes the state of the algorithm at the beginning of each iteration of the loop?

Iteration 1: (r mod 2) = 1 Iteration 2: (r mod 2) = 0 Iteration 3: (r mod 2) = 1 Iteration 4: (r mod 2) = 1

The loop executes 4 times on input y = 13. Which best describes the state of the algorithm at the beginning of each iteration of the loop?

Iteration 1: s = x Iteration 2: s = x^2 Iteration 3: s = x^4 Iteration 4: s = x^8

Principle of mathematical induction

Let S(n) be a statement parameterized by a positive integer n. Then S(n) is true for all positive integers n, if: 1.) S(1) is true (the base case) 2.) For all k ∈ Z+, S(k) implies S(k+1) (the inductive step).

Principle of strong mathematical induction

Let S(n) be a statement parameterized by n, a positive integer. Let a <= b be integers. Then S(n) is true for all n >= a, if the following two conditions hold: 1. S(a), S(a+1), ..., S(b) are true (the base case) 2. For all k>=b, if (S(a) ^ S(a+1) ^ ... ^ S(k)) is true, then S(k+1) is also true (the inductive step).

The Division Algorithm

Let n be an integer and let d be a positive integer. Then, there are unique integers q and r, with 0 <= r <= d - 1, such that n = qd + r

Congruence modulo n

Let n be an integer greater than 1. Let x and y be any two integers. Then x is congruent to y modulo n if x mod n = y mod n. The fact that x is congruent to y modulo n is denoted x ≡ y (mod n)

Alternate characterization of congruence modulo n

Let n be an integer greater than 1. Let x and y be any two integers. Then x ≡ y (mod n) if and only if n|(x-y)

Computing arithmetic operations modulo n

Let n be an integer larger than 1. Let x and y be any integers. Then [(x mod n) + (y mod n)] mod n = [x + y] mod n[(x mod n)(y mod n)] mod n = [x·y] mod n Alternatively, we could say that addition in Z is compatible with addition in Zn. That is, we could reduce first and then do the operation, or we could do the operation and then reduce. Often it simplifies the calculation to reduce as much as possible as a first step.

Dividing linear combinations

Let x, y, and z be integers. If x|y and x|z, then x|(sy+tz) for any integers s and t For example, since 6 divides both 12 and 18, 6 divides any linear combination of 12 and 18. The number 462 is a linear combination of 12 and 18 (19·12 + 13·18 = 462), so 6 divides 462.

********* Go back and do the 2.12 problems again!

Make sure to study the 2.12 problems that are long and drawn out extended euclidian algorithm structures-- you only have to do this when x is smaller than n... otherwise, you can guess what the coefficient is

The integers considered so far are relatively small, which has made recognizing whether the integers are prime or composite easier. However, many applications, particularly in cryptography, make use of very large numbers - on the order of several hundred digits. For example, consider the integer N below: N = 35201546659608842026088328007565866231962578784643756647773109869245232364730066609837018108561065242031153677

N has 110 digits. It is not at all clear how to determine whether a number of this magnitude is prime or composite. Given a potential factor x, it is possible to write a computer program to test if x|N. The running time of the program would scale with the number of digits in N, and if written properly, the program would run very quickly. The problem is how to know which potential factors to try. One approach is to test all potential factors. First, start with 2 and test if 2|N. If the answer is yes, then N is composite. If not, then go on and test 3. If 3|N, then N is composite. If not, go on to 4. Continue this process until either N is reached (in which case N is prime) or an integer less than N is found that divides N (in which case N is composite). If N is determined to be composite, the method described here will also find two integers greater than 1 whose product is N.

Does 8 divide 99?

No There is no integer k such that 99 = 8k.

What is the value of the output p at the end of the algorithm? x * x^2 * x^8 x * x^4 * x^8

The initial value for the variable is p = 1. p is multiplied by the current value of s in each iteration in which (r mod 2) = 1. (r mod 2) = 1 during iterations 1, 3, and 4. Therefore the output is x · x4 · x8.

Why Induction Works...Let's look at a little Proof-- this will likely be what we see on the test.

P(1) is true For all k>=1, P(k) implies P(k+1) k = 1 P(1) implies P(2) then P(2) is true k = 2 P(2) implies P(3) then P(3) is true k = 3 P(3) implies P(4) then P(4) is true For all n >= 1 P(n) is true Conclusion: P(1) and P(2) and P(3) and P(4) ... is true The implications continue ad infinitum. Therefore, for all n >= 1, P(n) is true

Consider an inductive prooof in which the inductive step is: For all k ≥ 6, if P(3), P(4),...,P(k) are all true, then P(k+1) is true.What facts must be proven in the base case? P(3) only. P(3), P(4), and P(5). P(3), P(4), P(5), and P(6).

P(3), P(4), P(5), and P(6) The base case must show that the inductive hypothesis is true for the smallest value for k. When k = 6, the inductive hypothesis is that P(3), P(4), P(5), and P(6) are true

Theorem: For all n ∈ Z+, Q(n) is true,where Q(n) is a statement that is parameterized by a positive integer n. If the inductive step says that for all positive integers Q(k) implies Q(k+1), then what is the inductive hypothesis? Q(k+1) Q(n) Q(k)

Q(k) is the hypothesis of the conditional statement that Q(k) implies Q(k+1)

__________________________ is a method that finds new values using previous values. To discuss recursions in-depth requires some new notation. To denote the nth term you write an. Using the example provided in the introduction, {7, 10, 13, 16, 19, 22, 25, ...} the 4th term is 16; written a4=16. The next term is denoted an+1 and the term after that is denoted an+2. In this example, a4+1 is term a5=19, and the next term after that a4+2 is a6=22. Similarly you use the notation an-1 and an-2 for the first and second term before an. Using the example above, a4=16, a4-1 is = 13, and a4-2 is a2= 10.

Recursion

In strong induction the inductive hypothesis is S(0) ∧ S(1) ∧ .... ∧ S(k). In regular (or weak) induction, the inductive hypothesis is just S(k). Sometimes the inductive hypothesis is expressed using a universal quantifier. The following two ways to express the inductive hypothesis are equivalent:

S(0) ∧ S(1) ∧ .... ∧ S(k) is true. ↔ For every j in the range 0 through k, S(j) is true.

The Prime Number Theorem

Says how dense primes numbers are among the integers Let pi(x) be the number of prime numbers in the range from 2 to x. Then lim(x to infinity) (pi(x)/(x/ln(x))) = 1 To help clarify what the Prime Number Theorem is saying, examine a smaller value for x, say x = 20. The number line below shows the integers in the range from 2 to 20. The blue dots represent prime numbers and the red dots represent composite numbers. The total number of dots is 19. The number of blue dots is 8. So the fraction of dots that are blue is 8/19 which is about .421. Now suppose we tried the same exercise for a very large x. The prime number theorem says that the fraction of dots that are blue is close to 1/ln x. For x = 10,000, the fraction of blue dots would be around 0.1086 and for x = 1,000,000,000, the fraction of blue dots would be around 0.048.

Suppose Bob selects prime numbers p=5 and q=11. Given the value for e found in the previous question, what is d?

Since (−17)7+(3)40=1, d=−17. In practice, only positive integers are used. Thus, the private key is d=−17+40=23.

Suppose Bob selects prime numbers p=5 and q=11. What integer e can be chosen between 5 and 8?

Since 40 = 2^3 * 5, e cannot be divisible by either 2 or 5. Thus, e = 7. The public key is N = 55 and e = 7

Preparation of public and private keys

Step 1: Bob selects two large prime numbers p and q p = 509 and q = 733 Step 2: Bob computes N = pq and φ=(p−1)(q−1) N=(509)(733)=373,097φ=(509−1)(733−1)=371856 Step 3: Bob finds an integer e such that gcd(e, φ)=1 Step 4: Bob computes the multiplicative inverse of e mod φ: an integer d such that ed mod φ. Step 5: Public (encryption) key: N and e the keys N = 373097 and e = 459173 are made public Step 6: Private (decryption) key: d The key d = 84173 is kept secret

_______________________ is used to express the sum of terms in a numerical sequence.

Summation notation

Two components of an inductive proof

The base case establishes that the theorem is true for the first value in the sequence - The genie grants you three wishes on day 1 The inductive step establishes that if the theorem is true for k, then the theorem also holds for k+1 - If you have three wishes on day k, then you can get three wishes for day k+1 (by using the third wish to ask for three more wishes the next day)

Asymptotic notation is a basic mathematical tool for working with functions that we only know up to a constant factor. There are three types of asymptotic notation that are commonly used in algorithmic analysis, O(n) ("big-O"), Ω(n) ("Omega"), and Θ(n) ("Theta").

The big-O notation—O(n)—serves as a rough upper bound for functions (disregarding constants and small input values). The Ω notation—Ω(n)—is similar to big-O, except that it provides a lower bound on the growth of a function. The Θ notation—Θ(n)—indicates how the algorithm performs for any case. This is referred to as an average time or random case function and, when possible, gives us a sense of how the algorithm performs in any case. Note that it is often possible to estimate upper and lower bounds, but not average cases especially if there are complex branching in the code.

The binary representation of 25 is 11001. Which expression is equivalent to b25?

The binary representation of 25 is 11001. Therefore 25 = 1·24 + 1·23 + 0·22 + 0·21 + 1·20 = 24 + 23 + 20 b^2^4⋅b^2^3⋅b^2^0=b^2^4+2^3+2^0=b^2^5

Instead of proving the theorem above, we illustrate how Euclid's algorithm can be used to find s and t that satisfy the equation. The key fact is that in each iteration of the loop, r is assigned the value (y mod x). Let d = y div x. According to the definition of the mod and div functions, y = dx + r, where r is an integer in the range from 0 to x - 1.

The equality can be rearranged to express r as a linear combination of x and y: r = y - dx. Thus, each iteration of the loop gives an equation expressing the current value of r as a linear combination of the current x and y. In the last iteration of the loop r = 0 and in the second to last iteration of the loop r is the gcd of the two input integers. The values for s and t in the theorem above can be found by a series of substitutions using the equation from each iteration. The algorithm used to find the coefficients, s and t, such that gcd(x, y) = sx + ty, is called the Extended Euclidean Algorithm.

To help you understand the effect of input size, let's look at two algorithms for calculating the nth element of the Fibonacci sequence. As you may recall, each element (term) of the sequence is the sum of the two previous ones. The first two elements of the Fibonacci sequence are both 1: {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...}.

The first algorithm to consider calculates the nth element by starting with the first two elements that are given, 1 and 1, calculates the third number by adding the first two, the fourth by adding the second and the third, and so on. So, to get to the nth element, this algorithm would have performed n−2 additions. When n=100, the algorithm needs 98 additions, and when n=1,000,002 we need one million additions to be executed to get the desired output.

A custom in the cryptography community is to name the two communicating parties "Alice" and "Bob". Alice is typically the person transmitting the message and Bob is the person receiving the message. There may be a third party eavesdropping onto the communication link between Alice and Bob who is often named "Eve".

The goal in cryptography is to design a system whereby, even if Eve can see the transmitted ciphertext from Alice to Bob, she is unable to decrypt the ciphertext without the secret key and learn the original plaintext.

Take a calculator and count how many times you will press the buttons for the arithmetic operations to calculate f(20). That will give you a good idea of how many more calculations are needed to complete the algorithm Fibonacci-1 than to complete Fibonacci-2.

This is an example of two algorithms that behave dramatically different as the size of the input increases. In the first one, the number of operations grows as n grows, and the second one the number of operations remains constant. It is only logical to use the second one since, regardless of the size of the input, it would always need less time to complete.

Compute 7^11

To compute 711, start with the binary expansion of 11, which is (1011)2. The place of each bit is numbered 3 to 0 from left to right. Therefore, 11 can be expressed as (1⋅23)+(0⋅22)+(1⋅21)+(1⋅20). Therefore, 711=7(1⋅23)+(0⋅22)+(1⋅21)+(1⋅20). The expression is equal to 7^(1⋅8)⋅7^(0⋅4)⋅7^(1⋅2)⋅7^(1⋅1). The powers of 7 can be computed by repeated squaring: 7^1=7, 7^2=49, 7^4=492=2401, and 7^8=20412=5764801. Note that 7^(0⋅4)=1, so that factor can be dropped. 7^11=7^8⋅7^2⋅7^1=5764801⋅49⋅7=1977326743.

A O(1) algorithm is Θ(1)

True

A Θ(n^2) algorithm is O(n^3)

True

A Θ(n) algorithm is O(n^2)

True As n^2 is bigger than n, this is true

RSA

We present now the most widely used public key cryptosystem developed by Rivest, Adelman, and Shamir in 1978, called the RSA cryptosystem after the initials of the inventors. The security of the RSA cryptosystem rests on the assumption that it is difficult to factor large numbers. If there were an efficient algorithm to factor numbers, then messages encrypted through RSA could be decrypted by someone who does not hold the matching decryption key.

Suppose that the inductive step of a strong induction proof shows that for k ≥ 1, if (S(0) ∧ S(1) ∧ .... ∧ S(k)) is true, then S(k+1) is true. If you assume that the inductive hypothesis is true, can you conclude that S(k-1) is true?

Yes

7 * 8 + 14 * 17 = 364. Does 7 divide 364?

Yes 364 is a linear combination of 7 and 14. 7 divides both 7 and 14

Don't be scared of math! You are actually quite good at math.

Your past failures are over in a box and they are because you were depressed. Also, when you associate something with failures, it triggers your fight or flight response because of your childhood. Wow crazy! Do the math! You're very good at it and it's fun!

Therefore, if n can be represented with k digits base b, then n ≤ bk - 1. The number of digits required to represent the base b expansion of n is the smallest integer k such that n + 1 ≤ bk. x = logb(n+1) is the real number such that n + 1 = bx. Certainly, the number of digits must be an integer and the number of digits must be at least logb(n+1). Therefore, the number of digits required to express the base b expansion of a positive integer n is ⌈logb⁡(n+1)⌉. For example, the number of digits required to express the base 2 expansion of 13 is: ⌈log2⁡(13+1)⌉=⌈log2⁡(14)⌉=⌈3.8⌉=4.

[log_2(13+1)] = [log_2(14)] = [3.8] = 4

While decimal notation is the representation typically used by humans, computers represent numbers in binary notation in which there are only two digits: 0 and 1. A digit in binary notation is called a _________. In binary notation, each place value is a power of 2. For example, the binary number 1011 corresponds to the decimal number 1·23 + 0·22 + 1·21 + 1·20 = 11. In fact, any integer greater than 1 can be used as the base of a number representation system. Numbers represented in _____________ b require b distinct symbols and each place value is a power of b. The fact that every integer greater than 1 gives rise to a unique system for number representation is summarized in the theorem below.

bit base

In the questions below, let N = 79 and k = 43. Use the simple cryptosystem defined above. c = (m + k) mod N Encrypt the plaintext m = 62

c = (62 + 43) mod 79 26 is the answer

Consider a simple cryptosystem in which the set of all possible plaintexts come from ZN for some integer N, for example N might be 28 if we allow for 26 lower case English characters, a space, and a period. Alice and Bob share a secret number k ∈ ZN. The security of their encryption scheme rests on the assumption that no one besides them knows the number k. To encrypt a plaintext m ∈ ZN, Alice computes:

c = (m + k) mod N (encryption)

Now suppose that Alice would like to send a plaintext message m to Bob. The RSA scheme requires that m is an integer in ZN and is not a multiple of p or q. Since p and q are primes with hundreds of digits, it is extremely unlikely that m is a multiple of primes p or q. Alice encrypts her plaintext using e and N to produce ciphertext c as follows:

c = m^e mod N (encryption)

A ______________________ for a sum is a mathematical expression that expresses the value of the sum without summation notation. There are closed form expressions for some, although not all, of the summations that arise naturally in scientific applications. For example, there is a closed form expression for the sum of terms in an arithmetic sequence:

closed form

An algorithm describes the underlying method for how a computational problem is solved. The choice of algorithms can have a dramatic effect on how efficiently the solution is obtained. The amounts of resources used by an algorithm is referred to as the algorithm's ______________________________. The goal of the computer scientist is to optimize the use of computer resources.

computational complexity

Our number system represents integers in _________________ notation in which each number is represented as sequences of digits. The set of digits has ten symbols: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. The place of a digit in the sequence represents its value. The rightmost digit is multiplied by 1 = 100, the digit that is second to the right is multiplied by 10 = 101. The digit that is kth from the right is multiplied by 10(k-1). For example, the number 256 represents 2·102 + 5·101 + 6·100.

decimal

To ensure accurate sending and receiving of messages, the encryption-decryption process must be one-to- one. That is, for each input there is one and only one output and vice versa. As you may recall from your study of functions, one-to- one functions map directly to their inverses. Thus, the encryption is a function whose domain (input value) is the characters possible in the message (m), and range (output value) is the set of all ciphertexts, c. Because this function is one-to- one, then the inverse function or _____________________________ function's domain is c and range is m; therefore, mapping the ciphertext back to the correct original plaintext message.

decryption

In a _____________________, a block of instructions is executed a fixed number of times as specified in the first line of the for-loop, which defines an index, a starting value for the index, and a final value for the index. Each repetition of the block of instructions inside the for-loop is called an iteration. The index is initially assigned a value equal to the starting value, and is incremented just before the next iteration begins. The final iteration of the for-loop happens when the index reaches the final value. In the example below, i is the index, s is the initial value, and t is the final value of the index.

for-loop For i = s to t Step 1 Step 2 . . . Step n End-for

The gcd of 24 and 50 is computed using the prime factorizations below:

gcd(24, 50) = 2^min(3,1) * 3^min(1,0) * 5^min(0,2) = 2^1 * 3^0 * 5^0 = 2

Select the choice that is equivalent to the recurrence relation: h_n = (h_(n-1))^3 for n >= 1

h_(k+1) = (h_k)^3 for k >= 0 This choice is obtained by replacing n with k+1 in the recurrence relation and the beginning value

In ________________________ notation (or hex for short), numbers are represented base 16. The 16 digits in hex are the usual 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 along with A, B, C, D, E, F. The table below shows each hexadecimal digit, its decimal encoding, and its binary encoding. Leading zeroes are added to the binary encodings so that all the encodings have exactly 4 bits.

hexadecimal

An if-else-statement tests a condition, executes one or more instructions if the condition evaluates to true, and executes a different set of instructions if the condition evaluates to false. The steps to be executed if the condition evaluates to true are indented below the if-statement. The steps to be executed if the condition evaluates for false are indented below the else statement, followed by a final end-if statement. If ( condition ) One or more steps Else One or more steps End-if

if-else-statement

An ________________________ tests a condition, and executes one or more instructions if the condition evaluates to true. In a single line if-statement, a condition and instruction appear on the same line. In the example below, if x currently has the value of 5, then y is assigned the value 7. If (x = 5), y := 7

if-statement

assignment

in which a variable is given a value. An assignment operator is denoted by: x := y The assignment statement above would change the value of x to be the current value of the variable y. It is also possible to assign a specific value to a variable as in x := 5, after which the value of x would be 5.

To control the iterations, for-loops use an _________________ or a counter and a variable that counts how many times a step or a block of steps executes. The index and counter variable specify the initial value of the counter and a step, or block of steps, to be executed before the counter is increased by 1. The statement or statements in the block will be executed for the incremented value of the counter over and over until the counter reaches its maximum specified value.

index

We just used _____________________ (not to be confused with inductive reasoning). Knowing that if the nth compartment filled then the (n+1)th compartment would fill, is the inductive step. For the dominos to start falling, the first compartment, n=1, had to fill; this is the base case. You have probably used induction many times before. In this lesson you will learn how to use induction as a mathematically rigorous direct proof appropriate for applications in logic and computer science.

induction

In the statement "S(k) implies S(k+1)" of the inductive step, the supposition that S(k) is true is called the ___________________________. The animation below illustrates why the principle of induction works by showing how the two components of an inductive proof imply that S(n) is true for any positive integer n:

inductive hypothesis

In _________________________, the input and output values must always be integers. For example, when the number 9 is divided by 4, the answer is 2 with a remainder of 1, instead of 2.25. In this chapter, the term "number" refers to an integer as opposed to a real number.

integer division

algorithm

is a step-by-step method for solving a problem. A description of an algorithm specifies the input to the problem, the output to the problem, and the sequence of steps to be followed to obtain the output from the input. A recipe is an example of an algorithm in which the ingredients are the input and the final dish is the output. A good recipe gives a clear sequence of steps indicating how to produce the dish from the ingredients.

An _____________________ is a process where a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met.

iteration

The least common multiple can be determined by using the larger of the two exponents for each prime number appearing in the prime factorization:

lcm(24, 50) = 2^max(3,1) * 3^max(1, 0) * 5^max(0,2) = 2^3 * 3^1 * 5^2 = 600

What would be the lcm of 924 = 2^2 * 3^1 * 5^0 * 7^1 * 11^1 33075 = 2^0 * 3^3 * 5^2 * 7^2 * 11^0

lcm(924, 33075) = 2^2 * 3^3 * 5^2 * 7^2* 11^1 This comes out to be 1455300

If a number x divides two different numbers, y and z, then x divides any linear combination of y and z. A ____________________________ of two numbers is the sum of multiples of those numbers. For example, 3x - 7y and -2x + 4y are both linear combinations of x and y. In most situations, the number in front of the variable, or the coefficient, can be any real number. However, for the material on the properties of integers, the term "linear combination" will assume integer coefficients. A statement about a generic linear combination uses variables to denote the integer coefficients. For example, sx + ty is a linear combination of x and y.

linear combination

The following pseudocode describes an algorithm that checks if the value V exists in the array a[1], a[2],...,a[n]: For i: = 1 to n If a[i]: = V, return (true) End-for Return(false) This method of searching for a value within an array is called __________________________. The asymptotic complexity for this algorithm is n due to the single for-loop. Note that this algorithm might not need to go through all n elements of the array to find one; however, in the worst-case scenario when it does (when no elements equals V or the last element of the array equals V), the loop will run n times. So, the asymptotic running time function for this algorithm's worst case is n. The algorithm searches for a value and is linear in complexity; thus, it is referred to as a linear search. Algorithms with one loop are usually of a linear running time complexity.

linear search

In the questions below, let N = 79 and k = 43. Use the simple cryptosystem defined above. c = (m + k) mod N Decrypt the ciphertext c = 26

m = (c - k) mod N = (26 - 43) mod 79 The answer is 62

Alice transmits c to Bob. Bob decrypts the ciphertext using d to recover m from c:

m = c^d mod N (decryption)

In the previous lesson you learned the division algorithm for integers and the operations of div and mod. In this lesson, you will be expanding your knowledge of this concept by incorporating the processes of addition and multiplication. The essence of this lesson lies in our usual understanding of integer addition or multiplication, with the assumption that the modular operation occurs afterward. For example, if we wanted to know the date 19 days from January 23, we could add 23 + 19 and get January 42. However, there's no such date as January 42, so in order to calculate the date you need to use __________________________________. In this example the month cycle is 31 days so you would use mod 31. The expression would be 42 mod 31, and the remainder is 11. Therefore, 19 days past January 23 would be February 11.

modular addition

The ________________________ of a prime factor p in a prime factorization is the number of times p appears in the product of primes. For example, in the prime factorization of 120 given above, the multiplicity of 2 is 3 and the multiplicity of 3 is 1. In order to express the prime factorization more compactly, we use exponential notation in which each distinct prime factor occurs only once and is raised to an exponent that is equal to its multiplicity. For example, the exponential notation for the prime factorization for 120 is

multiplicity **** 120 = 2^3 * 3 * 5

What is the asymptotic behavior of n + sqrt(n)

n

The input size for a problem is usually denoted by the variable _________, and the assessments of the algorithms' resources needs are denoted in functions of n that give the best-, worst-, and average-case scenario behavior of the algorithms. Not all elements of the complexity functions provide equally relevant information about how much more resources an algorithm would need as n grows.

n A combination of best-, worst-, and average- case analyses will give us a sense of how resource-intensive an algorithm is and whether to use it to achieve our goal if other algorithms that result in the same outcome are available or could be constructed.

The algorithm below checks if an array has any two elements that are the same: For i: = 1 to n For j: = 1 to n If a[i] = a[j], Return (true) End-for End-for Return(false) Since this algorithm has two nested loops within each other, it has an asymptotic behavior of _________.

n^2

What is the asymptotic behavior of n^2 + 3n + 112

n^2

What is the asymptotic behavior of n^3 + 1999n + 1337?

n^3

A _____________________ is a loop that appears within another loop. The nested loop, known as the inner loop, is treated as a sequence of steps inside the outer loop. A nested loop is illustrated below in an algorithm that counts the number of duplicate pairs in a sequence of numbers.

nested loop

Assignment, conditional, and iterative statements could comprise steps that execute in an iteration. Placing a loop within another loop is known as nesting. When a loop exists within another loop, it is called a ____________________. Both for- and while- loops can be nested in other for- or while-loops.

nested loop

A __________________________ sequence is a sequence in which each number is equal to or greater than the one that came before. For example, 1, 1, 2, 3, 17 is an example of a non-decreasing sequence, whereas the sequence 1, 1, 3, 2, 17 is not non-decreasing because 2 comes after 3. The number 120 has many prime factorizations. For example, 2·2·3·2·5 and 2·5·2·2·3 are both prime factorizations of 120. However, there is only one prime factorization of 120 in which the prime numbers are written in non-decreasing order: 2·2·2·3·5.

non-decreasing

The first mathematical objects most people encounter are integers. Integers are a natural component of everyday life and easy to understand. Even so, some of the deepest mathematical mysteries are found in ______________________, the branch of mathematics concerned with the study of integers. Number theory was studied primarily for its own sake for the better part of the last several thousand years, without any particular application as the goal. In the last few decades, however, number theory has emerged as a critical component of many applications, especially in computer science. In particular, number theory forms the mathematical basis for modern cryptography, the study of secure communication.

number theory

greatest common divisor (GCD)

of non-zero integers x and y is the largest positive integer that is a factor of both x and y

least common multiple (lcm)

of non-zero integers x and y is the smallest positive integer that is an integer multiple of both x and y

A cryptosystem is a system by which a sender sends a message to a receiver. The sender encrypts the message so that if an eavesdropper learns the transmitted message, she will be unable to recover the original message. The unencrypted message is called the ___________________ and the encrypted message is called the ___________________. The receiver must have a secret key that allows him to decrypt the ciphertext to obtain the original plaintext.

plaintext ciphertext

A number p is _________________ if it is an integer greater than 1 and its only factors are 1 and p. A positive integer is _________________ if it has a factor other than 1 or itself. Note that every integer greater than 1 is either prime or composite. Mathematicians have studied prime numbers for thousands of years. Prime numbers play a central role in number theory, as well as some of the deepest mysteries in mathematics. Prime numbers also play a key role in the design and analysis of modern cryptosystems.

prime composite

Prime numbers are the basic building blocks of all integers. Every positive integer greater than one can be expressed as a product of primes called its prime factorization. Moreover, the ____________________________ is unique up to ordering of the factors. The fact that every integer greater than one has a unique prime factorization is central to number theory and is called The Fundamental Theorem of Arithmetic.

prime factorization

The _____________________________ assumes that the fact to be proven holds for all values less than or equal to k and proves that the fact holds for k+1. By contrast the standard form of induction only assumes that the fact holds for k in proving that it holds for k+1. Define S(n) to be the assertion that fn ≤ 2n, where fn is defined by Fibonacci's initial values and recurrence relation.

principle of strong induction

In _________________________________, Bob has an encryption key that he provides publicly so that anyone can use it to send him an encrypted message. Bob holds a matching decryption key that he keeps privately to decrypt messages. While anyone can use the public key to encrypt a message, the security of the scheme depends on the fact that it is difficult to decrypt the message without having the matching private decryption key.

public key cryptography

Procedural version of the division algorithm

q := 0 r := n While ( r ≥ d ) q := q + 1 r := r - d End-While

In the Division Algorithm, the number q is called the ___________________________ and the number r is called the remainder. The operations div and mod produce the quotient and the remainder as a function of n and d. q = n div d r = n mod d

quotient

A ________________________________ is an equation that expresses a new term using previous terms. To write the equation you need two pieces of information: the initial terms and a rule defining the new term based on the previous term. The initial terms of the sequence are often notated a0 or a1. In this course, the initial term is denoted a0. In the previous example there was one initial term a0=7. However, recursion equations can have as many initial values as the relation defines. For example, let an=an-1+an-2+an-3 for n ≥ 4 with initial values a0=1, a1=1, and a2=4. The number of initial terms used by an equation will be equal to the number of previous terms present in the equation. For example, an=2×an-1+an-2 requires 2 initial terms.

recurrence relation

Two numbers are said to be ______________________ if their greatest common divisor is 1. The greatest common divisor and least common multiple are fundamental concepts in number theory. Computing the greatest common divisor of two numbers is also a step in the RSA cryptosystem described later in this material.

relatively prime

The output of an algorithm is specified by a __________________ statement. For example, the statement Return(x) would return the value of x as the output of the algorithm. A return statement in the middle of an algorithm causes the execution of the algorithm to stop at that point and return the indicated value.

return

The summation of sequences (also called ___________________) are one of the powerful tools in mathematics and computer science because they are necessary for the approximations and evaluations of functions. In this lesson you will start with a review of summation terms, notations, and computations. Then you will learn how to pull out a final term from a summation.

series

The primary resources to optimize are _________________________, the time the algorithm requires to run, and _____________________, the amount of memory used. Together they are respectively referred to as time and space complexity of the algorithm. The time depends on the speed of the processing unit, the number of calculations that need to be performed, the number of conditions that need to be evaluated, or the number of iterations to be completed by the loops. At the same time, the values of all variables, including the values of the input variables and all other values that will be computed, need to be stored somewhere in the memory of the system—in the RAM, hard drive, or external devices.

time complexity space complexity

In the previous lesson you learned about the structure and use of an inductive proof. Induction can be used to prove statements about any discrete set that can be ordered (a ________________________________). That is, any set that can be counted, like your fingers, arranged from least to greatest, and has a smallest value is called a well-ordered set. This applies to most things in our world. This is why number theory is an important element of computer science and why induction is such a useful and elegant tool.

well-ordered set

pseudocode

which is a detailed yet readable description of what an algorithm must do, expressed in a formally-styled natural language rather than in a programming language. Steps are formatted carefully as indented lists so as to convey the structure of the approach. The steps themselves are expressed in brief English phrases or mathematical symbols.

The ____________________ is similar to the for-loop in that it provides a way to specify that a sequence of steps should be repeated. A for-loop specifies the number of iterations in advance, via the beginning and ending index values. A while-loop iterates an unknown number of times, ending when a certain condition becomes false

while-loop While ( condition ) Step 1 Step 2 . . . Step n End-while

The functions f(n) and g(n) are called upper and lower bounds of the asymptotic complexity of the algorithm and the following is true by definition:

Ω(f(n)) ≤ Θ(f(n)) ≤ O(f(n)).


Kaugnay na mga set ng pag-aaral

CEA 1º ESO TEMA 7: CLASIFICACIÓN DE LOS SERES VIVOS

View Set

Chapter 11 Product, Branding, and Packaging Decisons

View Set

Chapter 2 Quiz Attempt 1 (10/10)

View Set

Chapter 28: Types of Investment Properties

View Set

Hearing Conservation, Occupational and Recreational Noise-Induced Hearing Loss

View Set

Chapter 5: The Structure and Function of Large Biological Molecules

View Set

Chapter 2: Chemistry and Measurements

View Set

ch 26- practice questions - Health Assessment PrepU, Fundamentals of Nursing III (Chap 25 Prep U Questions), Chapter 26: Health Assessment

View Set