Fall 2017 November 10, Written Homework 5

Size: px
Start display at page:

Download "Fall 2017 November 10, Written Homework 5"

Transcription

1 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 November 10, 2017 Assigned: Mon Nov Due: Wed Nov Instructions: Written Homework 5 The assignment has to be uploaded to blackboard by the due date. NO assignment will be accepted after 11:59pm on that day. We expect that you will study with friends and often work out problem solutions together, but you must write up your own solutions, in your own words. Cheating will not be tolerated. Professors, TAs, and peer tutors will be available to answer questions but will not do your homework for you. One of our course goals is to teach you how to think on your own. We require that all homework submissions be neat and easily readable. We recommend using a word processor like Microsoft Word or L A TEX for your submissions. If you scan your homework, you may lose points if the scan is not legible. To get full credit, show INTERMEDIATE steps leading to your answers, throughout. You can give answers that are probabilities as either fully simplified fractions or decimal answers to at least two nonzero digits. Problem 1 [12 pts (3,3,3,3)]: Sequences For each of the following lists of integers, (1) indicate whether the sequence is arithmetic, geometric, quadratic, or none of these and (2) give a simple formula that generates the terms of this sequence, where your list elements begin at n = 1. For example, the sequence is arithmetic and generated by the formula starting at n = 1. i. 5, 1, 3, 7, 11, 15,... 3, 5, 7, 9, 11,... a n = 2n + 1 Solution: This is an arithmetic sequence since the difference between consecutive terms is a constant (in this case, 4). The sequence starts at 5 for n = 1 and increases by 4 for each subsequent term. As such, the solution is a n = 5 + (n 1) 4 = 4n 9 1

2 ii. 2, 6, 18, 54, 162, 486,... Solution: This is a geometric series since the ratio between consecutive terms is a constant (in this case, 3). The sequence starts at 2 for n = 1 and changes by a factor of 3 for each subsequent term. As such, the solution is a n = 2 ( 3) n 1 = 2 3 ( 3)n iii. 0, 5, 16, 33, 56, 85,... Solution: The ratio between consecutive terms is not constant, so the sequence is not geometric. The first differences (5, 11, 17, 23,...) are also not constant, so the sequence is not arithmetic. However, the second differences are constant (in this case, 6), so the sequence is quadratic. Quadratic sequences can be solved in multiple ways; here we set up 3 equations in 3 unknowns to determine the solution. Every quadratic sequence is of the form a n = a n 2 + b n + c for some constants a, b, c. To determine these constants, we set up 3 equations in 3 unknowns by considering the values of a n for n = 1, 2, 3. n = 1 : 0 = a b 1 + c n = 2 : 5 = a b 2 + c n = 3 : 16 = a b 3 + c Simplifying and rearranging the equations, we have: a + b + c = 0 (1) 4a + 2b + c = 5 (2) 9a + 3b + c = 16 (3) Subtracting Equation 1 from Equation 2, and subtracting Equation 2 from Equation 3, we obtain: Finally, subtracting Equation 4 from Equation 5, we obtain 3a + b = 5 (4) 5a + b = 11 (5) 2a = 6. Solving for a, we obtain a = 3. Substituting this value of a into Equations 4 or 5 yields b = 4. Finally, substituting these values of a and b into Equations 1, 2, or 3 yields c = 1. Thus, our solution is a n = 3n 2 4n

3 iv. 6, 12, 24, 48, 96, 192,... Solution: This is a geometric series since the ratio between consecutive terms is a constant (in this case, 2). The sequence starts at 6 for n = 1 and changes by a factor of 2 for each subsequent term. As such, the solution is a n = 6 2 n 1 = 3 2 n. Problem 2 [16 pts (4,4,4,4)] Sums Evaluate the following sums. You must apply the methods given in class and in the text; i.e., you cannot simply add the numbers with a calculator or write a program. Show your work, and your final answer should be a single integer. i Solution: This is an arithmetic series, as the difference between consecutive terms is a constant (in this case, 5). Arithmetic series can be solved in multiple ways; here we apply Gauss s trick as discussed in class and the text. Let S be the sum, and write the series forwards and backwards: S = S = Now, if we sum the two equations, we obtain 2S on the left-hand side. On the right-hand side, summing term-by-term, we obtain 57 for each summand. 2S = The number of terms on the right-hand side is and thus 66 ( 9) 5 As such, we have S = 16 57/2 = 8 57 = 456. ii = 16 2S = Solution: This is a geometric series, as the ratio between consecutive terms is a constant (in this case, 3). Geometric series can be solved in multiple ways; here we apply the method discussed in class and the text. Let S be the sum, and write the series for S and 3S: S = S = Now, if we subtract the first equation from the second, the terms 6, 18,..., 1458 all cancel and we obtain 3S S =

4 or simplified As such, we have S = 4372/2 = S = Derive formulas in terms of n for the following sums. You must show your work, and your final formula should only contain n and integers (but not k). iii. iv. n (3k 1) k=4 Solution: Writing out the terms of the series, we have n (3k 1) = (3n 1). k=4 This is an arithmetic series, as the difference between consecutive terms is a constant (in this case, 3). Again, arithmetic series can be solved in multiple ways; here we apply the method discussed in class and the text. Let S be the sum, and write the series forwards and backwards: S = (3n 1) S = (3n 1) + (3n 4) + (3n 7) Now, if we sum the two equations, we obtain 2S on the left-hand side. On the right-hand side, summing term-by-term, we obtain 3n + 10 for each summand. 2S = (3n + 10) + (3n + 10) + + (3n + 10). Since the summation is from k = 4 to n, there are n = n 3 terms; thus, As such, we have n 4 5 k+2 k=3 2S = (n 3) (3n + 10). S = (n 3)(3n + 10) 2 Solution: Writing out the terms of the series, we have n 4 5 k+2 = n+2. k=3 This is a geometric series, as the ratio between consecutive terms is a constant (in this case, 5). Again, geometric series can be solved in multiple ways; here we apply the method discussed in class and the text. Let S be the sum, and write the series for S and 5S: S = n+2 5S = n+3 4

5 Now, if we subtract the first equation from the second, the terms n+2 all cancel and we obtain 5S S = 4 5 n or simplified As such, we have S = 5 n S = 4 (5 n ). Problem 3 [18 pts (6,4,8)]: Comparisons of Functions In class, we discussed quadratic sorting algorithms (Insertion-Sort and Selection-Sort) and an n lg n sorting algorithm (Merge-Sort). Dozens, if not hundreds, of other sorting algorithms have been developed. Another well-known sorting algorithm is Shell-Sort whose asymptotic running time is on the order of n lg 2 n, when implemented appropriately. In the problems that follow, you will compare these three algorithms for sorting. Ignoring lower order terms and constant factors, let T 1 (n), T 2 (n), and T 3 (n) be the effort required by Insertion-Sort, Shell-sort, and Merge-Sort, respectively, to sort a list of length n. We have where lg n is log 2 (n). T 1 (n) = n 2 T 2 (n) = n lg 2 n T 3 (n) = n lg n i. Suppose that you were given a budget of 100,000 units of effort. For each of the three algorithms, determine the largest list length such that the sorting effort required is guaranteed to be at most 100,000. Solution: For T 1 (n) = n 2, we want n such that n The solution is As such, n = 316 is the largest such list. n = For T 2 (n) = n lg 2 n we want n such that n lg 2 n This cannot be solved analytically, but as stated in the hint, you can easily use binary search. We essentially want to solve the equation n lg 2 n = To apply binary search, we start with two values of n, one too small and one too large, and then we examine the midpoint between these values. If the midpoint is too small, we repeat on the right-half; if too large, we repeat on the left half. We can trivially start with n = 1 as a value that is too small since 1 lg 2 1 < and n = as a 5

6 value that is too large since lg > Applying binary search, we obtain the following tests and results: Thus we see the solution is n n lg 2 n For T 3 (n) = n lg n we want n such that n lg n This cannot be solved analytically, but as before we can use binary search. We essentially want to solve the equation n lg n = To apply binary search, we start with two values of n, one too small and one too large, and then we examine the midpoint between these values. If the midpoint is too small, we repeat on the right-half; if too large, we repeat on the left half. We can trivially start with n = 1 as a value that is too small since 1 lg 1 < and n = as a value that is too large since lg > Applying binary search, we 6

7 obtain the following tests and results: Thus we see the solution is n n lg n ii. How many times larger is the list that Merge-Sort can handle, as compared to the lists that Insertion-Sort and Shell-sort can handle? How many times larger is the list that Shell-sort can handle, as compared to the list that Insertion-Sort can handle? Solution: The maximum list sizes for Merge-Sort, Shell-sort, and Insertion-Sort are 7740, 1005, and 316, respectively. Thus, (1) Merge-Sort can handle a list 7740/1005 = 7.7 times larger than Shell-sort and 7740/316 = 24.5 times larger than Insertion-Sort; (2) Shell-sort can handle a list 1005/316 = 3.18 times larger than Insertion-Sort. iii. Suppose you are running the three algorithms on three different computers. The computer running Insertion-Sort is 5 times faster than the one running Shell-sort, and the computer running Shell-sort is 20 times faster than the one running Merge-Sort. How large must the list be before the computer running Merge-Sort begins to outperform the one running Shell-sort? How large must the list be before the computer running Shell-sort begins to outperform the one running Insertion-Sort? Solution: Merge-Sort vs. Shell-sort: To sort lists of size n, Merge-Sort takes n lg n units of effort and Shell-sort takes n lg 2 n units of effort. However, since the computer running Merge-Sort is 20 times slower than the computer running Shell-sort, we must find an n such that 20n lg n < n lg 2 n. 7

8 Dividing both sides of this equation by n lg n, we obtain or 20 < lg n n > 2 20 = 1, 048, 576. Thus, for n = 1, 048, 577 (or larger), Merge-Sort will outperform Shell-sort, even when run on a computer 20 times slower. Shell-sort vs. Insertion-Sort: To sort lists of size n, Shell-sort takes n lg 2 n units of effort and Insertion-Sort takes n 2 units of effort and. However, since the computer running Shell-Sort is 5 times slower than the computer running Shell-sort, we must find an n such that 5n lg 2 n < n 2. This cannot be solved analytically, but we can use binary search as before. We essentially want to solve the equation 5n lg 2 n = n 2. To apply binary search, we start with two values of n, one too small and one too large, and then we examine the midpoint between these values. If the midpoint is too small, we repeat on the right-half; if too large, we repeat on the left half. We can start with n = 5 as a value that is too small since 5 5 lg 2 5 > 5 2 and n = 1000 as a value that is too large since lg = 496, and = 1, 000, 000. Applying binary search, we obtain the following tests and results: n 5n lg 2 n n Thus we see the solution is 361, since 5n lg 2 n > n 2 at n = 360 but 5n lg 2 n < n 2 at n = 361. Hint: For each question in part iii, you can write an equation that indicates that the running times of the two algorithms being compared are equal, taking into account the speeds of the computers on which the algorithms are being run. For part i, you can also write an equation to be solved. These equations may involve n lg n and n lg 2 n, and in general, they cannot always be solved analytically. You can solve these equations, however, by using binary search. See Exercise 11.3 in the text for 8

9 more hints on solving such equations. Your answers need only be accurate to the units place, e.g., 123 as opposed to Problem 4 [12 pts (3,3,3,3)]: Search Algorithms In binary search, we split the list in half, perform one comparison to determine if our target element is in the first or second half, and repeat on the appropriate half as necessary until only one element remains. Since there are at most log 2 n halving operations, we use at most 1 log 2 n = log 2 n comparisons in the worst-case. Now consider ternary search instead. Here we would split the list into thirds, perform (at most) 2 comparisons to determine which third contains our target element, and repeat on the appropriate third as necessary until only one element remains. i. What is the worst-case number of comparisons performed by ternary search? Explain. Solution: If we split a list into thirds, the pieces are of size n/3. If we split into thirds again, the pieces are of size (n/3)/3 = n/3 2. In general, if we split into thirds k times, the pieces would be of size n/3 k. We can do this until the pieces are of size 1; therefore, the maximum number of times we can split a list into thirds corresponds to the value of k where n/3 k = 1. Solving for k, we obtain k = log 3 n. Thus, we can split a list into thirds at most log 3 n times. Each time we split the list, we perform (at most) 2 comparisons. Thus, the worst-case number of comparisons for ternary search is 2 log 3 n. ii. Which algorithm performs fewer comparisons in the worst-case, and by how much? Your answer should be in the form, Algorithm A performs x-times fewer comparisons than Algorithm B, for appropriate values of A, B, and x. Hint: The following mathematical fact may come in handy; it allows one to change the base of a logarithm. log a n = log b n/ log b a. Solution: Ternary search requires 2 log 3 n comparisons (in the worst case); binary search requires log 2 n comparisons (in the worst case). Let s put everything in terms of log 2. Using the fact that log a n = log b n/ log b a, we have that log 3 n = log 2 n/ log 2 3. Thus, ternary search requires 2 log 3 n = 2 log 2 3 log 2 n in the worst case. Since 2/ log 2 3 = 1.262, ternary search performs times more comparisons than binary search (in the worst case) or, equivalently, binary search performs times fewer comparisons than ternary search. Let us now generalize to k-ary search, where we split the list into k equal size groups and perform (at most) k 1 comparisons to determine the appropriate group on which to repeat. iii. What is the worst-case number of comparisons performed by k-ary search? Explain. Solution: Generalizing the above argument, we can perform a k-ary split at most log k n times, and each split entails (at most) k 1 comparisons for a total of (at most) comparisons. (k 1) log k n 9

10 iv. What is the integer value of k which minimizes the number of comparisons in the worst-case? Explain. Hint: Ensure that your expression from part iii is in the form f(k) log 2 n for some function f(k). To do this, make use of the fact that log a n = log b n/ log b a, as you did above. Solution: Let s again put everything in terms of log 2. Since log k n = log 2 n/ log 2 k, we have (k 1) log k n = k 1 log 2 k log 2 n. As k grows, k 1 grows much faster than log 2 k, so the factor (k 1)/ log 2 k gets bigger as k grows. Here are the factors for the first few values of k: (2 1)/ log 2 2 = 1 (3 1)/ log 2 3 = (4 1)/ log 2 4 = 1.5 (5 1)/ log 2 5 = 1.72 The best value of k is the smallest, k = 2, which corresponds to binary search. Problem 5 [42 pts (8,6,8,6,6,8)]: Induction and Recurrences 1. Solve the following recurrence (assuming T (1) = 1). T (n) = 8T (n/2) + n 3 Solution: We begin by iterating the recurrence until we notice a pattern. T (n) = n 3 + 8T (n/2) = n ( (n/2) 3 + 8T ((n/2)/2) ) = 2n T (n/2 2 ) = 2n ( (n/2 2 ) 3 + 8T ((n/2 2 )/2) ) = 3n T (n/2 3 ) We now begin to see a pattern, and our conjecture is that k 1, the iterative pattern T (n) = k n k T (n/2 k ) holds. We will prove this conjecture true via induction later. Our recurrence will reach a base case when n/2 k = 1 or k = log 2 n. At that point, we obtain T (n) = (log 2 n) n log 2 n T (n/2 log 2 n ) = n 3 log 2 n + n log 2 8 T (1) = n 3 log 2 n + n 3 Our derivation is complete once we prove our conjecture that k 1, the iterative pattern holds. We do so by induction. T (n) = k n k T (n/2 k ). 10

11 Base case: At k = 1 we have T (n) = 1 n T (n/2 1 ) = n 3 + 8T (n/2) which is our original recurrence. Thus, our base case holds. Inductive step: Show that if our pattern holds for k 1, i.e., then our pattern must hold for k, i.e., T (n) = (k 1) n k 1 T (n/2 k 1 ) T (n) = k n k T (n/2 k ). Starting with our assumption and iterating the recurrence, we obtain Thus our proof is complete. T (n) = (k 1) n k 1 T (n/2 k 1 ) = (k 1) n k 1( (n/2 k 1 ) 3 + 8T ((n/2 k 1 )/2) ) = k n k T (n/2 k ). 2. The Fibonacci numbers 1, 1, 2, 3, 5, 8,... is a sequence defined by the equation F n = F n 1 + F n 2 where F 1 = 1 and F 2 = 1. Consider a currency system with Fibonacci denominations. In other words, unlike the US currency system which has $1, $5, $10, $20, $50,... denominations, we would have $1, $2, $3, $5, $8, $13,... denominations. In what follows, we will show that the Fibonacci currency system is efficient in that very few bills are needed to make change for any value $d. Consider the standard greedy algorithm for making change: To make change for $d, you would choose the largest denomination less than or equal to d, subtract that denomination value from d, and then repeat for the remainder. For example, to make change for $19 in the US currency system, we would choose a $10 bill, yielding a remainder of $9. We would then choose a $5 bill, yielding a remainder of $4. We would then choose a $1 bill, yielding a remainder of $3, and so on. Our change would then be $10, $5, $1, $1, $1, $1. Applying the same greedy strategy in the Fibonacci system, our change would be $13, $5, $1. 11

12 i. In making change for $d using the greedy strategy, let F n be the largest Fibonacci denomination value less than or equal to d. (1) Argue that F n d < F n+1. (2) Prove that after choosing an F n bill, the remainder d F n must satisfy d F n < F n 1. Solution: (1) Since F n is the largest Fibonacci denomination less than or equal to d, we have F n d by construction. Furthermore, we must have d < F n+1 or else F n is not the largest Fibonacci denomination less than or equal to d. Combining these results, we have F n d < F n+1. (2) We note that F n+1 = F n + F n 1 by the definition of the Fibonacci sequence. Since d < F n+1, we then have d < F n+1 = F n + F n 1. Subtracting F n 1 from both sides of the above inequality yields d F n < F n 1. ii. Prove by induction that for any dollar value $d, you can make change for $d without using any denomination more than once and without the use of adjacent denominations. For example, while you could make change for $14 using two $5 bills, one $3 bill, and one $1 bill, you would be using a denomination twice (the $5 bill) and you would be using adjacent denominations (the $5 and $3 bills). One could instead use one $13 and one $1 bill, which are non-adjacent and without repetition. Hint: Make use of the results from part i. Solution: Strong induction. The base case d = 1 is obvious; we simply use a single $1 bill, satisfying our constraints. Strong inductive step: Assume true for all k < d; show for d. Let F n be the largest Fibonacci number less than or equal to d; begin by picking a single F n bill. If d = F n, then we are done and have satisfied our constraints. Otherwise, we must make change for the remaining d F n ; since d F n < d, we can make change for this remaining amount using non-adjacent bills without repetition by our inductive hypothesis. Furthermore, we have that d F n < F n 1 from part i. Therefore, when we make change for the remaining d F n, we do not need an F n 1 (or higher) bill. Thus, combining our single F n bill with the change we made for d F n using non-adjacent bills without repetition all strictly smaller than F n 1, we obtain an overall solution meeting our criteria. iii. Prove that if change is being made with n denominations d 1, d 2,..., d n and adjacent denominations are not allowed, then at most n/2 unique denominations can be used. For simplicity, you may assume that n is even; the more general result for n odd or even is that at most n/2 unique denominations can be used. Hint: Try a proof by contradiction, group the denominations in adjacent pairs, and employ the Pigeonhole Principle. Solution: Suppose, for the sake of contradiction, that the claim is false. Then it must be possible to make change with n/2 + 1 (or more) unique denominations and not have adjacent denominations. Consider the denominations in adjacent pairs: {d 1, d 2 }, {d 3, d 4 },..., {d n 1, d n }. There are n/2 such pairs. By the Pigeonhole Principle, if we select n/2 + 1 (or more) unique denominations, then at least one of the adjacent pairs must have been selected 12

13 twice, violating our constraint. Thus, our assumption is false and the claim must be true. The following is not required, but here is the proof for n odd. Suppose, for the sake of contradiction, that the claim is false. Then it must be possible to make change with n/2 + 1 (or more) unique denominations and not have adjacent denominations. Consider the denominations in adjacent pairs with one denomination left over: {d 1, d 2 }, {d 3, d 4 },..., {d n 2, d n 1 }, d n There are n/2 such groups. By the Pigeonhole Principle, if we select n/2 + 1 (or more) unique denominations, then at least one of the groups must have been selected twice. This cannot be the last group (which contains only one denomination), since we are selecting unique denominations. Therefore, one of the pairs must have been selected twice, violating our constraint. Thus, our assumption is false and the claim must be true. iv. Prove by induction that n 6, F n 2 n/2. Note that 2 n/2 = ( 2) n n. Solution: Strong induction. Base cases n = 6 and n = 7 are easy. Strong inductive step: Assume true for all 6 k < n; show for n. We have: F n = F n 1 + F n 2 ( 2) n 1 + ( 2) n 2 = ( 2) n 2 ( 2 + 1) > ( 2) n 2 2 = ( 2) n v. Given the results of the previous parts, prove (not necessarily by induction) that d 8 it is always possible to make change for $d in the Fibonacci currency system using at most log 2 d bills. Hint: Start by considering the largest Fibonacci denomination F n in any such solution and then use the result from part iv above to bound the size of n. You will then need the results from other parts above to finish the proof. Solution: Let F n be the largest denomination used to make change for $d. We must have that F n d. Combining with the result of part iv above, we have that d F n 2 n/2. Solving for n, we obtain n 2 log 2 d. Thus, we are making change with denominations F 1, F 2, F 3, F 4,..., F 2 log2 d which is 2 log 2 d different bills. 1 By the result of part ii, it is possible to use at most one of each such bill; hence, at most 2 log 2 d bills total. Furthermore, by the result of part ii, we need not use adjacent bills. By the result of part iii, without adjacent bills, we would not use more than half the denominations; thus, at most log 2 d bills total. less. 1 Technically, we won t use both F 1 and F 2, since they are both 1, so the number of unique bills is actually one 13

Fall 2017 September 20, Written Homework 02

Fall 2017 September 20, Written Homework 02 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 September 20, 2017 Assigned: Wed 20 Sep 2017 Due: Fri 06 Oct 2017 Instructions: Written Homework 02 The assignment has to be uploaded to

More information

Solutions to Assignment 1

Solutions to Assignment 1 Solutions to Assignment 1 Question 1. [Exercises 1.1, # 6] Use the division algorithm to prove that every odd integer is either of the form 4k + 1 or of the form 4k + 3 for some integer k. For each positive

More information

Summer 2017 June 16, Written Homework 03

Summer 2017 June 16, Written Homework 03 CS1800 Discrete Structures Prof. Schnyder Summer 2017 June 16, 2017 Assigned: Fr 16 June 2017 Due: Tu 20 June 2017 Instructions: Written Homework 0 The assignment has to be uploaded to Blackboard by the

More information

CS1800 Discrete Structures Final Version A

CS1800 Discrete Structures Final Version A CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 11, 2017 CS1800 Discrete Structures Final Version A Instructions: 1. The exam is closed book and closed notes. You may not use

More information

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3 Banner ID: Name: Midterm Exam CS 3110: Design and Analysis of Algorithms June 20, 2006 Group 1 Group 2 Group 3 Question 1.1 Question 2.1 Question 3.1 Question 1.2 Question 2.2 Question 3.2 Question 3.3

More information

CS1800: Strong Induction. Professor Kevin Gold

CS1800: Strong Induction. Professor Kevin Gold CS1800: Strong Induction Professor Kevin Gold Mini-Primer/Refresher on Unrelated Topic: Limits This is meant to be a problem about reasoning about quantifiers, with a little practice of other skills, too

More information

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers. MATH 4 Summer 011 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If

More information

Standard forms for writing numbers

Standard forms for writing numbers Standard forms for writing numbers In order to relate the abstract mathematical descriptions of familiar number systems to the everyday descriptions of numbers by decimal expansions and similar means,

More information

Fall 2017 Test II review problems

Fall 2017 Test II review problems Fall 2017 Test II review problems Dr. Holmes October 18, 2017 This is a quite miscellaneous grab bag of relevant problems from old tests. Some are certainly repeated. 1. Give the complete addition and

More information

CS 161 Summer 2009 Homework #2 Sample Solutions

CS 161 Summer 2009 Homework #2 Sample Solutions CS 161 Summer 2009 Homework #2 Sample Solutions Regrade Policy: If you believe an error has been made in the grading of your homework, you may resubmit it for a regrade. If the error consists of more than

More information

Research Methods in Mathematics Homework 4 solutions

Research Methods in Mathematics Homework 4 solutions Research Methods in Mathematics Homework 4 solutions T. PERUTZ (1) Solution. (a) Since x 2 = 2, we have (p/q) 2 = 2, so p 2 = 2q 2. By definition, an integer is even if it is twice another integer. Since

More information

Given a sequence a 1, a 2,...of numbers, the finite sum a 1 + a 2 + +a n,wheren is an nonnegative integer, can be written

Given a sequence a 1, a 2,...of numbers, the finite sum a 1 + a 2 + +a n,wheren is an nonnegative integer, can be written A Summations When an algorithm contains an iterative control construct such as a while or for loop, its running time can be expressed as the sum of the times spent on each execution of the body of the

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction Math 4 Summer 01 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If

More information

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation: CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe

More information

Putnam Greedy Algorithms Cody Johnson. Greedy Algorithms. May 30, 2016 Cody Johnson.

Putnam Greedy Algorithms Cody Johnson. Greedy Algorithms. May 30, 2016 Cody Johnson. 1 Introduction Greedy Algorithms May 0, 2016 Cody Johnson ctj@math.cmu.edu A greedy algorithm is an algorithm that chooses the optimal choice in the short run. 2 Examples 1. Prove that every nonnegative

More information

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime. PUTNAM TRAINING NUMBER THEORY (Last updated: December 11, 2017) Remark. This is a list of exercises on Number Theory. Miguel A. Lerma Exercises 1. Show that the sum of two consecutive primes is never twice

More information

CS1802 Week 11: Algorithms, Sums, Series, Induction

CS1802 Week 11: Algorithms, Sums, Series, Induction CS180 Discrete Structures Recitation Fall 017 Nov 11 - November 17, 017 CS180 Week 11: Algorithms, Sums, Series, Induction 1 Markov chain i. Boston has days which are either sunny or rainy and can be modeled

More information

Introduction to Divide and Conquer

Introduction to Divide and Conquer Introduction to Divide and Conquer Sorting with O(n log n) comparisons and integer multiplication faster than O(n 2 ) Periklis A. Papakonstantinou York University Consider a problem that admits a straightforward

More information

Proof Techniques (Review of Math 271)

Proof Techniques (Review of Math 271) Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil

More information

CS1800: Mathematical Induction. Professor Kevin Gold

CS1800: Mathematical Induction. Professor Kevin Gold CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size

More information

Math 109 HW 9 Solutions

Math 109 HW 9 Solutions Math 109 HW 9 Solutions Problems IV 18. Solve the linear diophantine equation 6m + 10n + 15p = 1 Solution: Let y = 10n + 15p. Since (10, 15) is 5, we must have that y = 5x for some integer x, and (as we

More information

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS 1. Cardinal number of a set The cardinal number (or simply cardinal) of a set is a generalization of the concept of the number of elements

More information

Notes on arithmetic. 1. Representation in base B

Notes on arithmetic. 1. Representation in base B Notes on arithmetic The Babylonians that is to say, the people that inhabited what is now southern Iraq for reasons not entirely clear to us, ued base 60 in scientific calculation. This offers us an excuse

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

COM S 330 Lecture Notes Week of Feb 9 13

COM S 330 Lecture Notes Week of Feb 9 13 Monday, February 9. Rosen.4 Sequences Reading: Rosen.4. LLM 4.. Ducks 8., 8., Def: A sequence is a function from a (usually infinite) subset of the integers (usually N = {0,,, 3,... } or Z + = {,, 3, 4,...

More information

PRACTICE PROBLEMS: SET 1

PRACTICE PROBLEMS: SET 1 PRACTICE PROBLEMS: SET MATH 437/537: PROF. DRAGOS GHIOCA. Problems Problem. Let a, b N. Show that if gcd(a, b) = lcm[a, b], then a = b. Problem. Let n, k N with n. Prove that (n ) (n k ) if and only if

More information

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,

More information

CMSC Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005

CMSC Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005 CMSC-37110 Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005 Instructor: László Babai Ryerson 164 e-mail: laci@cs This exam contributes 20% to your course grade. 1. (6 points) Let a

More information

PART 1: USING SCIENTIFIC CALCULATORS (41 PTS.) 1) The Vertex Form for the equation of a parabola in the usual xy-plane is given by y = 3 x + 4

PART 1: USING SCIENTIFIC CALCULATORS (41 PTS.) 1) The Vertex Form for the equation of a parabola in the usual xy-plane is given by y = 3 x + 4 MIDTERM SOLUTIONS (CHAPTERS AND 3: POLYNOMIAL, RATIONAL, EXP L, LOG FUNCTIONS) MATH 141 FALL 018 KUNIYUKI 150 POINTS TOTAL: 41 FOR PART 1, AND 109 FOR PART PART 1: USING SCIENTIFIC CALCULATORS (41 PTS.)

More information

Assignment 16 Assigned Weds Oct 11

Assignment 16 Assigned Weds Oct 11 Assignment 6 Assigned Weds Oct Section 8, Problem 3 a, a 3, a 3 5, a 4 7 Section 8, Problem 4 a, a 3, a 3, a 4 3 Section 8, Problem 9 a, a, a 3, a 4 4, a 5 8, a 6 6, a 7 3, a 8 64, a 9 8, a 0 56 Section

More information

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation: Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O

More information

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty.

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty. EXAM 2 solutions (COT3100, Sitharam, Spring 2017) NAME:last first: UF-ID Section NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty. (1) Are the following functions one-to-one

More information

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm:

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: The maximum-subarray problem Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: Brute force algorithm: At best, θ(n 2 ) time complexity 129 Can we do divide

More information

Welcome to CSE21! Lecture B Miles Jones MWF 9-9:50pm PCYN 109. Lecture D Russell (Impagliazzo) MWF 4-4:50am Center 101

Welcome to CSE21! Lecture B Miles Jones MWF 9-9:50pm PCYN 109. Lecture D Russell (Impagliazzo) MWF 4-4:50am Center 101 Welcome to CSE21! Lecture B Miles Jones MWF 9-9:50pm PCYN 109 Lecture D Russell (Impagliazzo) MWF 4-4:50am Center 101 http://cseweb.ucsd.edu/classes/sp16/cse21-bd/ March 30, 2016 Sorting (or Ordering)

More information

Induction and recursion. Chapter 5

Induction and recursion. Chapter 5 Induction and recursion Chapter 5 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms Mathematical Induction Section 5.1

More information

Reductions, Recursion and Divide and Conquer

Reductions, Recursion and Divide and Conquer Chapter 5 Reductions, Recursion and Divide and Conquer CS 473: Fundamental Algorithms, Fall 2011 September 13, 2011 5.1 Reductions and Recursion 5.1.0.1 Reduction Reducing problem A to problem B: (A) Algorithm

More information

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms 1 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms 2 Section 5.1 3 Section Summary Mathematical Induction Examples of

More information

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4 Do the following exercises from the text: Chapter (Section 3):, 1, 17(a)-(b), 3 Prove that 1 3 + 3 + + n 3 n (n + 1) for all n N Proof The proof is by induction on n For n N, let S(n) be the statement

More information

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Algorithms (II) Yu Yu. Shanghai Jiaotong University Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:

More information

CS1800 Discrete Structures Fall 2016 Profs. Gold & Schnyder April 25, CS1800 Discrete Structures Final

CS1800 Discrete Structures Fall 2016 Profs. Gold & Schnyder April 25, CS1800 Discrete Structures Final CS1800 Discrete Structures Fall 2016 Profs. Gold & Schnyder April 25, 2017 CS1800 Discrete Structures Final Instructions: 1. The exam is closed book and closed notes. You may not use a calculator or any

More information

4 a b 1 1 c 1 d 3 e 2 f g 6 h i j k 7 l m n o 3 p q 5 r 2 s 4 t 3 3 u v 2

4 a b 1 1 c 1 d 3 e 2 f g 6 h i j k 7 l m n o 3 p q 5 r 2 s 4 t 3 3 u v 2 Round Solutions Year 25 Academic Year 201 201 1//25. In the hexagonal grid shown, fill in each space with a number. After the grid is completely filled in, the number in each space must be equal to the

More information

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2. MATH 55 - HOMEWORK 6 SOLUTIONS Exercise Section 5 Proof (a) P () is the statement ( ) 3 (b) P () is true since ( ) 3 (c) The inductive hypothesis is P (n): ( ) n(n + ) 3 + 3 + + n 3 (d) Assuming the inductive

More information

Exercise Sheet #1 Solutions, Computer Science, A M. Hallett, K. Smith a k n b k = n b + k. a k n b k c 1 n b k. a k n b.

Exercise Sheet #1 Solutions, Computer Science, A M. Hallett, K. Smith a k n b k = n b + k. a k n b k c 1 n b k. a k n b. Exercise Sheet #1 Solutions, Computer Science, 308-251A M. Hallett, K. Smith 2002 Question 1.1: Prove (n + a) b = Θ(n b ). Binomial Expansion: Show O(n b ): (n + a) b = For any c 1 > b = O(n b ). Show

More information

CS383, Algorithms Spring 2009 HW1 Solutions

CS383, Algorithms Spring 2009 HW1 Solutions Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ 21 Campanella Way, room 569 alvarez@cs.bc.edu Computer Science Department voice: (617) 552-4333 Boston College fax: (617) 552-6790 Chestnut Hill,

More information

SMT 2013 Power Round Solutions February 2, 2013

SMT 2013 Power Round Solutions February 2, 2013 Introduction This Power Round is an exploration of numerical semigroups, mathematical structures which appear very naturally out of answers to simple questions. For example, suppose McDonald s sells Chicken

More information

STUDY GUIDE Math 20. To accompany Intermediate Algebra for College Students By Robert Blitzer, Third Edition

STUDY GUIDE Math 20. To accompany Intermediate Algebra for College Students By Robert Blitzer, Third Edition STUDY GUIDE Math 0 To the students: To accompany Intermediate Algebra for College Students By Robert Blitzer, Third Edition When you study Algebra, the material is presented to you in a logical sequence.

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 Data Structures and Algorithms Chapter 3 1. Divide and conquer 2. Merge sort, repeated substitutions 3. Tiling 4. Recurrences Recurrences Running times of algorithms with recursive calls can be described

More information

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2 Induction 0-8-08 Induction is used to prove a sequence of statements P(), P(), P(3),... There may be finitely many statements, but often there are infinitely many. For example, consider the statement ++3+

More information

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

5 + 9(10) + 3(100) + 0(1000) + 2(10000) = Chapter 5 Analyzing Algorithms So far we have been proving statements about databases, mathematics and arithmetic, or sequences of numbers. Though these types of statements are common in computer science,

More information

Mathematical Background. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0.

Mathematical Background. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0. Mathematical Background Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 N k=0 log k 0 e x2 e π i 1 = 0 dx a+b a + b https://ece.uwaterloo.ca/~cmoreno/ece250 Mathematical Background Standard reminder to set

More information

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score: Name & UID: Circle Your Section! 0101 (10am: 3120, Ladan) 0102 (11am: 3120, Ladan) 0103 (Noon: 3120, Peter) 0201 (2pm: 3120, Yi) 0202 (10am: 1121, Vikas) 0203 (11am: 1121, Vikas) 0204 (9am: 2117, Karthik)

More information

We are going to discuss what it means for a sequence to converge in three stages: First, we define what it means for a sequence to converge to zero

We are going to discuss what it means for a sequence to converge in three stages: First, we define what it means for a sequence to converge to zero Chapter Limits of Sequences Calculus Student: lim s n = 0 means the s n are getting closer and closer to zero but never gets there. Instructor: ARGHHHHH! Exercise. Think of a better response for the instructor.

More information

CDM Combinatorial Principles

CDM Combinatorial Principles CDM Combinatorial Principles 1 Counting Klaus Sutner Carnegie Mellon University Pigeon Hole 22-in-exclusion 2017/12/15 23:16 Inclusion/Exclusion Counting 3 Aside: Ranking and Unranking 4 Counting is arguably

More information

Chapter 1. Pigeonhole Principle

Chapter 1. Pigeonhole Principle Chapter 1. Pigeonhole Principle Prof. Tesler Math 184A Fall 2017 Prof. Tesler Ch. 1. Pigeonhole Principle Math 184A / Fall 2017 1 / 16 Pigeonhole principle https://commons.wikimedia.org/wiki/file:toomanypigeons.jpg

More information

Mathematics 228(Q1), Assignment 2 Solutions

Mathematics 228(Q1), Assignment 2 Solutions Mathematics 228(Q1), Assignment 2 Solutions Exercise 1.(10 marks) A natural number n > 1 is said to be square free if d N with d 2 n implies d = 1. Show that n is square free if and only if n = p 1 p k

More information

RMT 2014 Power Round Solutions February 15, 2014

RMT 2014 Power Round Solutions February 15, 2014 Introduction This Power Round develops the many and varied properties of the Thue-Morse sequence, an infinite sequence of 0s and 1s which starts 0, 1, 1, 0, 1, 0, 0, 1,... and appears in a remarkable number

More information

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6 CS 70 Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6 1 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes

More information

Algorithms Exam TIN093 /DIT602

Algorithms Exam TIN093 /DIT602 Algorithms Exam TIN093 /DIT602 Course: Algorithms Course code: TIN 093, TIN 092 (CTH), DIT 602 (GU) Date, time: 21st October 2017, 14:00 18:00 Building: SBM Responsible teacher: Peter Damaschke, Tel. 5405

More information

CS 2110: INDUCTION DISCUSSION TOPICS

CS 2110: INDUCTION DISCUSSION TOPICS CS 110: INDUCTION DISCUSSION TOPICS The following ideas are suggestions for how to handle your discussion classes. You can do as much or as little of this as you want. You can either present at the board,

More information

Induction and Recursion

Induction and Recursion . All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Induction and Recursion

More information

Divide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14

Divide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14 Divide and Conquer Algorithms CSE 101: Design and Analysis of Algorithms Lecture 14 CSE 101: Design and analysis of algorithms Divide and conquer algorithms Reading: Sections 2.3 and 2.4 Homework 6 will

More information

THE DIVISION THEOREM IN Z AND R[T ]

THE DIVISION THEOREM IN Z AND R[T ] THE DIVISION THEOREM IN Z AND R[T ] KEITH CONRAD 1. Introduction In both Z and R[T ], we can carry out a process of division with remainder. Theorem 1.1. For any integers a and b, with b nonzero, there

More information

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You: CS70 Discrete Mathematics and Probability Theory, Fall 2018 Midterm 1 8:00-10:00pm, 24 September Your First Name: SIGN Your Name: Your Last Name: Your Exam Room: Name of Person Sitting on Your Left: Name

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.4 Strong Mathematical Induction and the Well-Ordering Principle for the Integers Copyright

More information

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency

More information

CS1800: Sequences & Sums. Professor Kevin Gold

CS1800: Sequences & Sums. Professor Kevin Gold CS1800: Sequences & Sums Professor Kevin Gold Moving Toward Analysis of Algorithms Today s tools help in the analysis of algorithms. We ll cover tools for deciding what equation best fits a sequence of

More information

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, Divide and Conquer CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Merging sorted lists: WHAT Given two sorted lists a 1 a 2 a 3 a k b 1 b 2 b 3 b

More information

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions

More information

Introduction to Basic Proof Techniques Mathew A. Johnson

Introduction to Basic Proof Techniques Mathew A. Johnson Introduction to Basic Proof Techniques Mathew A. Johnson Throughout this class, you will be asked to rigorously prove various mathematical statements. Since there is no prerequisite of a formal proof class,

More information

The Euclidean Algorithm

The Euclidean Algorithm MATH 324 Summer 2006 Elementary Number Theory Notes on the Euclidean Algorithm Department of Mathematical and Statistical Sciences University of Alberta The Euclidean Algorithm Given two positive integers

More information

THESIS. Presented in Partial Fulfillment of the Requirements for the Degree Master of Science in the Graduate School of The Ohio State University

THESIS. Presented in Partial Fulfillment of the Requirements for the Degree Master of Science in the Graduate School of The Ohio State University The Hasse-Minkowski Theorem in Two and Three Variables THESIS Presented in Partial Fulfillment of the Requirements for the Degree Master of Science in the Graduate School of The Ohio State University By

More information

CS2223 Algorithms D Term 2009 Exam 3 Solutions

CS2223 Algorithms D Term 2009 Exam 3 Solutions CS2223 Algorithms D Term 2009 Exam 3 Solutions May 4, 2009 By Prof. Carolina Ruiz Dept. of Computer Science WPI PROBLEM 1: Asymptoptic Growth Rates (10 points) Let A and B be two algorithms with runtimes

More information

Design and Analysis of Algorithms Lecture Notes on Convex Optimization CS 6820, Fall Nov 2 Dec 2016

Design and Analysis of Algorithms Lecture Notes on Convex Optimization CS 6820, Fall Nov 2 Dec 2016 Design and Analysis of Algorithms Lecture Notes on Convex Optimization CS 6820, Fall 206 2 Nov 2 Dec 206 Let D be a convex subset of R n. A function f : D R is convex if it satisfies f(tx + ( t)y) tf(x)

More information

Algorithms Design & Analysis. Analysis of Algorithm

Algorithms Design & Analysis. Analysis of Algorithm Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of

More information

Fibonacci mod k. In this section, we examine the question of which terms of the Fibonacci sequence have a given divisor k.

Fibonacci mod k. In this section, we examine the question of which terms of the Fibonacci sequence have a given divisor k. Fibonacci mod k I start by giving out a table of the first 0 Fibonacci numbers actually the first, because we begin with u 0 =0 (and I have a reason for that which will soon become apparent). Okay, which

More information

CHAPTER 3. Sequences. 1. Basic Properties

CHAPTER 3. Sequences. 1. Basic Properties CHAPTER 3 Sequences We begin our study of analysis with sequences. There are several reasons for starting here. First, sequences are the simplest way to introduce limits, the central idea of calculus.

More information

Warm-up Quantifiers and the harmonic series Sets Second warmup Induction Bijections. Writing more proofs. Misha Lavrov

Warm-up Quantifiers and the harmonic series Sets Second warmup Induction Bijections. Writing more proofs. Misha Lavrov Writing more proofs Misha Lavrov ARML Practice 3/16/2014 and 3/23/2014 Warm-up Using the quantifier notation on the reference sheet, and making any further definitions you need to, write the following:

More information

Mathematical Proofs. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0.

Mathematical Proofs. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0. Mathematical Proofs Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 N k=0 log k 0 e x2 e π i 1 = 0 dx a+b a + b https://ece.uwaterloo.ca/~cmoreno/ece250 Mathematical Proofs Standard reminder to set phones

More information

CSC236 Week 3. Larry Zhang

CSC236 Week 3. Larry Zhang CSC236 Week 3 Larry Zhang 1 Announcements Problem Set 1 due this Friday Make sure to read Submission Instructions on the course web page. Search for Teammates on Piazza Educational memes: http://www.cs.toronto.edu/~ylzhang/csc236/memes.html

More information

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem CS 577 Introduction to Algorithms: Jin-Yi Cai University of Wisconsin Madison In the last class, we described InsertionSort and showed that its worst-case running time is Θ(n 2 ). Check Figure 2.2 for

More information

Computer Science Foundation Exam

Computer Science Foundation Exam Computer Science Foundation Exam May 6, 2016 Section II A DISCRETE STRUCTURES NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question Max Pts Category Passing

More information

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms CompSci 102 Discrete Math for Computer Science Announcements Read for next time Chap. 3.1-3.3 Homework 3 due Tuesday We ll finish Chapter 2 first today February 7, 2012 Prof. Rodger Chap. 3.1 Algorithms

More information

Definitions. Notations. Injective, Surjective and Bijective. Divides. Cartesian Product. Relations. Equivalence Relations

Definitions. Notations. Injective, Surjective and Bijective. Divides. Cartesian Product. Relations. Equivalence Relations Page 1 Definitions Tuesday, May 8, 2018 12:23 AM Notations " " means "equals, by definition" the set of all real numbers the set of integers Denote a function from a set to a set by Denote the image of

More information

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri MATH 1101 haalshehri@ksu.edu.sa 1 Introduction To Number Systems First Section: Binary System Second Section: Octal Number System Third Section: Hexadecimal System 2 Binary System 3 Binary System The binary

More information

3 Finite continued fractions

3 Finite continued fractions MTH628 Number Theory Notes 3 Spring 209 3 Finite continued fractions 3. Introduction Let us return to the calculation of gcd(225, 57) from the preceding chapter. 225 = 57 + 68 57 = 68 2 + 2 68 = 2 3 +

More information

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10 Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 10 CSE 101: Design and analysis of algorithms Greedy algorithms Reading: Kleinberg and Tardos, sections 4.1, 4.2, and 4.3 Homework 4

More information

Table of Contents. 2013, Pearson Education, Inc.

Table of Contents. 2013, Pearson Education, Inc. Table of Contents Chapter 1 What is Number Theory? 1 Chapter Pythagorean Triples 5 Chapter 3 Pythagorean Triples and the Unit Circle 11 Chapter 4 Sums of Higher Powers and Fermat s Last Theorem 16 Chapter

More information

Algorithms: Lecture 2

Algorithms: Lecture 2 1 Algorithms: Lecture 2 Basic Structures: Sets, Functions, Sequences, and Sums Jinwoo Kim jwkim@jjay.cuny.edu 2.1 Sets 2 1 2.1 Sets 3 2.1 Sets 4 2 2.1 Sets 5 2.1 Sets 6 3 2.1 Sets 7 2.2 Set Operations

More information

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence Section 2.4 Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations Introduction Sequences are ordered lists of elements.

More information

Mathematical Fundamentals

Mathematical Fundamentals Mathematical Fundamentals Sets Factorials, Logarithms Recursion Summations, Recurrences Proof Techniques: By Contradiction, Induction Estimation Techniques Data Structures 1 Mathematical Fundamentals Sets

More information

CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication

CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication 1 Introduction We have now seen that the Fast Fourier Transform can be applied to perform polynomial multiplication

More information

Advanced Counting Techniques. Chapter 8

Advanced Counting Techniques. Chapter 8 Advanced Counting Techniques Chapter 8 Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence Relations Nonhomogeneous Recurrence Relations Divide-and-Conquer

More information

3 The language of proof

3 The language of proof 3 The language of proof After working through this section, you should be able to: (a) understand what is asserted by various types of mathematical statements, in particular implications and equivalences;

More information

Solutions to Tutorial 4 (Week 5)

Solutions to Tutorial 4 (Week 5) The University of Sydney School of Mathematics and Statistics Solutions to Tutorial 4 (Week 5) MATH2069/2969: Discrete Mathematics and Graph Theory Semester 1, 2018 1. Prove by induction that, for all

More information

CSCI Honor seminar in algorithms Homework 2 Solution

CSCI Honor seminar in algorithms Homework 2 Solution CSCI 493.55 Honor seminar in algorithms Homework 2 Solution Saad Mneimneh Visiting Professor Hunter College of CUNY Problem 1: Rabin-Karp string matching Consider a binary string s of length n and another

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

Solutions Quiz 9 Nov. 8, Prove: If a, b, m are integers such that 2a + 3b 12m + 1, then a 3m + 1 or b 2m + 1.

Solutions Quiz 9 Nov. 8, Prove: If a, b, m are integers such that 2a + 3b 12m + 1, then a 3m + 1 or b 2m + 1. Solutions Quiz 9 Nov. 8, 2010 1. Prove: If a, b, m are integers such that 2a + 3b 12m + 1, then a 3m + 1 or b 2m + 1. Answer. We prove the contrapositive. Suppose a, b, m are integers such that a < 3m

More information

Math 016 Lessons Wimayra LUY

Math 016 Lessons Wimayra LUY Math 016 Lessons Wimayra LUY wluy@ccp.edu MATH 016 Lessons LESSON 1 Natural Numbers The set of natural numbers is given by N = {0, 1, 2, 3, 4...}. Natural numbers are used for two main reasons: 1. counting,

More information

Mathematical Proofs. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0.

Mathematical Proofs. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0. Mathematical Proofs Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 N k=0 log k 0 e x2 e π i 1 = 0 dx a+b a + b https://ece.uwaterloo.ca/~cmoreno/ece250 Today's class: Mathematical Proofs We'll investigate

More information