Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010

Size: px
Start display at page:

Download "Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010"

Transcription

1 Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Midterm Problem 1: Recall that for two functions g : N N + and h : N N +, h = Θ(g) iff for some positive integer N and positive real numbers c 1 and c 2, for every n N, c 1 g(n) h(n) c 2 g(n). Also, h = O(g) iff for some positive integer N and positive real number c, for every n N, h(n) c g(n). Let f : N N +. (I.e. Let f map nonnegative integers to positive integers) where f(n) = (((cos nπ) + 1)n) Part 1: Show that f(n) = O(n 2 ) Hint: Give the upper scaling constant (the constant c in the Big-O definition) and threshold in your argument. Answer: First, let s understand f(n). For [n = 0, 1, 2,... ], [cos nπ = 1, 1, 1, 1,... ]. Therefore, [((cos nπ)+1) = 2, 0, 2, 0... ] as [n = 0, 1, 2,... ], and [f(n) = (2 0) 2 + 1, (0 1) 2 + 1, (2 2) 2 + 1, (0 3) 2 + 1,... ]; i.e. [f(n) = (2 0) 2 + 1, (0 1) 2 + 1, (2 2) 2 + 1, (0 3) 2 + 1,... ]. In other words, { 4n if n is even f(n) = 1 if n is odd

2 Therefore, the alternation in the ratio f(n) n 2 = { 4n 2 n 2 = 4 if n is even if n is odd 1 n 2 f(n) prevents lim from existing; i.e the limit is said to be undefined. To show n n 2 that f(n) = O(n 2 ) we must find a threshold and upper scaling constant as is required by the definition of Big-O. For all even n 1, f(n) = 4n n 2. For all odd n, f(n) = 1 5n 2. Thus, we can take c = 5 and N = 1 in the definition of Big-O. Part 2: Show that f(n) Θ(n 2 ) Hint: Show that every real number fails as a lower scaling constant (the constant c 1 in the Θ-definition). Answer: Consider any possible threshold N. Let c 1 be a positive real number. Suppose for all n N, c 1 n 2 f(n) Studyguide Problem 1: The next major step in the argument is: For all odd n N c 1 1 n 2 Explain how this step in the argument follows from one or more previous major steps. Studyguide Problem 2: The next major step in the argument is: For all odd n N c 1 = 0

3 Explain how this step in the argument follows from one or more previous major steps. Contradiction. Therefore, no positive real number can serve as a lower scaling constant to meet the criteria for f(n) = Θ(n 2 ). Midterm Problem 2: The natural logarithm (in fact, all logarithms with bases greater than 1) is a convex function. That means, for any nonnegative real numbers a 1 and a 2, where a 1 + a 2 = 1, a 1 ln x 1 + a 2 ln x 2 ln(a 1 x 1 + a 2 x 2 ) (You don t have to prove that.) In general, any nonnegative real number valued function f defined on an interval of real numbers [a, b], where [a, b] = {x R a x b} f is said to be convex iff for any x 1, x 2 [a, b], a 1 f(x 1 ) + a 2 f(x 2 ) f(a 1 x 1 + a 2 x 2 ) Part 1: Use the convexity of ln to prove that n ln n (n 1) ln(n + 1) Hint: Let x 1 = 1 and x 2 = n+1. Let a 2 = n 1. (On the midterm I originally n said to let x 1 = n.) Answer: Studyguide Problem 3: Apply the substitutions indicated in the hint to part 1 to the inequality that defines the convexity property for the ln function

4 and simplify the right hand side so that it becomes ln n. Do not use the fact that ln 1 = 0 to simplify the inequality on the left hand side. Studyguide Problem 4: Multiply through the inquality by n to obtain the result called for in part 1. Studyguide Problem 5: Redo this problem using a real number valued convex function f that is convex on all intervals [1, r] for every r > 1. Studyguide Problem 6: Explain why the result you are asked to prove in part 1 depends only the convexity of ln and no other properties of ln. Part 2: Use mathematical induction and the result of part 1 (whether or not you succeeded in proving part 1) to prove that for all n 1, ln n! = ln 1 + ln ln n 1 2 n ln n Answer: There are two steps to this ordinary induction proof: the base step, where in this case, n = 1, and the induction step. Base step (n = 1): It must be proved that the result holds for the case where n = 1. Studyguide Problem 7: Write the mathematical statement that must be proved where n = 1. Both sides of the inequality that is the answer to studyguide problem 7 evaluate to 0. Therefore the inequality holds.

5 Induction step: We must prove that for every n 1, if ln n! 1 2 n ln n, then ln(n + 1)! 1 (n 1) ln(n + 1) 2 To prove this conditional statement, assume the if part, also known as the hypothesis, of the conditional statement. That is, assume ln n! 1 2 n ln n In the context of an induction proof, this assumption is known as the induction hypothesis. Studyguide Problem 8: Explain why the assumption of the induction hypothesis that was just made does not assume what we are trying to prove. It follows that ln(n + 1)! = ln n! + ln(n + 1) [Studyguide Problem 9: Why?] 1 n ln n + ln(n + 1) [Studyguide Problem 10: Why?] 2 1 (n 1) ln(n + 1) + ln(n + 1) [Studyguide Problem 11: Why?] 2 = 1 (n + 1) ln(n + 1) [Studyguide Problem 12: Why?] 2 Therefore, by the principle of mathematical induction, for every n 1, ln n! 1 2 n ln n Studyguide Problem 13: State the principle of mathematical induction. Midterm Problem 3: Consider

6 k = 0; a = 1; while (a <= n) { a = 2*a; k = k + a; } Use Θ-notation to express, in terms of the value n of n, both the number of times the loop executes, and the value of k upon termination. Answer: To get a feel for what happens in the while-loop, do the following: Studyguide Problem 14: Write down the list of pairs of values (a, k) each time the condition (a <= n) is checked during execution of the loop. It will help if you write the values of a and k in base 2. Think of n, the value of n, as large. It might also help if your list of the pairs of values is written vertically. Studyguide Problem 15: Argue that each time the loop condition (a <= n) is checked, a is a power of 2 and (a, k) = (a, 2a 2). The loop terminates when the value of a is the least power of 2 that equals or exceeds the value of n. Studyguide Problem 16: Argue that the loop terminates in Θ(ln n) steps. Argue that the value of k upon termination is also Θ(ln n). Midterm Problem 4: Part 1: Using Θ-notation, express the number of bits in n! in terms of n. Answer: The number of bits in a nonnegative integer m is Θ(ln m). There-

7 fore the number of bits in n! is Θ(ln n!). Via midterm problem 2 we saw (eventually) that ln n! = Θ(n ln n). Therefore, we could, optionally, but usefully, simplify Θ(ln n!) to Θ(n ln n). Part 2: Analyze the runtime of the following algorithm: k = n; a = 1; while (k > 1) { a = a*k; k = k - 1; } Answer: The loop is executed n 1 times, as the value of k ranges successively from the value n of n down to 1, but the loop is not executed when the value of n is 1. The time cost of one execution of the loop is the time taken to check whether (k > 1) is true, which is Θ(1), plus the cost of executing a = a*k;, which is the time cost of performing the multiplication a*k plus the time cost of assigning the result of the multiplication to a, which is Θ(1), plus the time cost of performing the decrement of k which is Θ(1). The time taken to perform multiplication of two integers dominates the other time costs. If we use a naive divide-and-conquer algorithm to perform a multiplication, the time cost is Θ(m 2 ) where m is the number of bits in the larger of the two integers to be multiplied. Using Gauss s trick we could reduce the exponent to log 2 3. Using an adaptation of the Fourier transform to perform the multiplication, we can reduce the time complexity to Θ(m ln m). Studyguide Problem 17: Show that whenever the condition (k > 1) to n! enter the loop is checked, the value of a is. This relation among the (n k)!

8 values of n, a and k is a loop invariant that implies that upon termination of the loop the value of a is n!. The total time taken is then Θ(ln n ln ln n) + Θ((ln n + ln(n 1)) ln(ln n + ln(n 1))) Θ((ln n + ln(n 1) ln 2) ln(ln n + ln(n 1) ln 2)) Note: Using the time complexity Θ((ln n) 2 ) of naive divide-and-conquer multiplication, I accepted Θ(n(ln n) 2 ) as an estimate of the time complexity for full credit, or equivalently, Θ(n m 2 ), where m is the number of bits in n. Midterm Problem 5: Let p be a prime number. Assume that there is a probability distribution on {1,..., (p 1)} such that the probability of drawing any single number from this set is the same as drawing any other number from this set. That is, assume there is a uniform distribution on {1,..., (p 1)}. Part 1: Let a and b be elements of the set {1,..., (p 1)}. What is the probability that b a 1 (mod p)? Answer: a and b may be the same element. In mathematical writing, two different symbols may refer to the same entity unless otherwise specified. For each a in {1,..., (p 1)} there is exactly one element b in {1,..., (p 1)} such that b a 1 (mod p). Therefore the probability of a and b being in the right relationship is the one chance among the number of elements 1 in {1,..., (p 1)}; i.e.. [See the reasoning in Dasgupta et.al., p. p 1 46 ( internet edition ) concerning the proof of a probabilistic property of universal hash function choices.] Part 2: Let a, b, c be randomly selected from {1,..., (p 1)}. What is the probability that a b c (mod p)?

9 Answer: The answer is again 1 p 1. Studyguide Problem 18: Why? The reasoning is almost exactly the same as for part 1. Midterm Problem 6: The following result is known as the Master Theorem for recurrence relations. Let T : N N such that T (n) = a T ( n b ) + O(nd ) for some real number constants a > 0, b > 0, and d 0. Then O(n d ) if d > log b a T (n) = O(n d ln n) if d = log b a O(n log b a ) if d < log b a Solve the following recurrence: T (n) = 49 T (n/25) + n 3/2 ln n Answer: First, the ceiling notation in the equation for T (n) can be ignored in the Master Theorem. It s included in the statement of the theorem for cases where it might be needed. Studyguide Problem 19: Show that for any real number ɛ > 0 and d 1 n d ln n = O(n d+ɛ ) Arguments making use of limits will work here. Studyguide Problem 20: Show that n d ln n O(n d+ɛ )

10 Again, arguments making use of limits will work. Studyguide Problem 21: Follow the instructions of the Master Theorem to solve T (n) = 49 T (n/25) + n 3/2+ɛ To follow these instructions, ɛ must be compared with log Show, by reasoning, not be using a calculator, that 25 3/2 > 49. Therefore, for each ɛ > 0, as well as for ɛ = 0, d + ɛ > log Studyguide Problem 22: Verify that, by the Master Theorem, that T (n) = O(n 3/2 ln n) solves T (n) = 49 T (n/25) + n 3/2+ɛ Note: An argument such as the one above earned full credit. The argument that T (n) = O(n 3/2 ) that was shown in class also earned full credit. But the idea with recurrences is to get the fastest growing function that satisfies the recurrence relation. So: Studyguide Problem 23: Show that T (n) = O(n 3/2 ln n) solves T (n) = 49 T (n/25) + n 3/2 ln n

11 using the more powerful version of the Master Theorem given at Studyguide Problem 24: The Fast Fourier Transform, (FFT) is given in Das Gupta et.al. as function FFT(A, ω) Input: Coefficient representation of a polynomial A(x) of degree n 1, where n is a power of 2 ω, an n th root of unity Output: Value representation [A(ω 0 ),..., A(ω n 1 )] if ω = 1: return A(1) express A(x) in the form A e (x 2 ) + xa o (x 2 ) call FFT(A e, ω 2 ) to evaluate A e at even powers of ω call FFT(A o, ω 2 ) to evaluate A o at even powers of ω for j = 0 to n 1: compute A(ω j ) = A e (ω 2j ) + ω j A o (ω 2j ) return A(ω 0 ),..., A(ω n 1 ) Apply the FFT to the polynomial 3 + 4x + 6x 2 + 2x 3.

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Complexity Analysis Complexity Theory Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Output TRUE or FALSE Time and Space

More information

Divide-and-Conquer and Recurrence Relations: Notes on Chapter 2, Dasgupta et.al. Howard A. Blair

Divide-and-Conquer and Recurrence Relations: Notes on Chapter 2, Dasgupta et.al. Howard A. Blair Divide-and-Conquer and Recurrence Relations: Notes on Chapter 2, Dasgupta et.al. Howard A. Blair 1 Multiplication Example 1.1: Carl Friedrich Gauss (1777-1855): The multiplication of two complex numbers

More information

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013 /4/3 Administrative Big O David Kauchak cs3 Spring 3 l Assignment : how d it go? l Assignment : out soon l CLRS code? l Videos Insertion-sort Insertion-sort Does it terminate? /4/3 Insertion-sort Loop

More information

Big-oh stuff. You should know this definition by heart and be able to give it,

Big-oh stuff. You should know this definition by heart and be able to give it, Big-oh stuff Definition. if asked. You should know this definition by heart and be able to give it, Let f and g both be functions from R + to R +. Then f is O(g) (pronounced big-oh ) if and only if there

More information

Reading 10 : Asymptotic Analysis

Reading 10 : Asymptotic Analysis CS/Math 240: Introduction to Discrete Mathematics Fall 201 Instructor: Beck Hasti and Gautam Prakriya Reading 10 : Asymptotic Analysis In the last reading, we analyzed the running times of various algorithms.

More information

NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt):

NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt): CS 170 First Midterm 26 Feb 2010 NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt): Instructions: This is a closed book, closed calculator,

More information

Algorithms and Their Complexity

Algorithms and Their Complexity CSCE 222 Discrete Structures for Computing David Kebo Houngninou Algorithms and Their Complexity Chapter 3 Algorithm An algorithm is a finite sequence of steps that solves a problem. Computational complexity

More information

Integer-Valued Polynomials

Integer-Valued Polynomials Integer-Valued Polynomials LA Math Circle High School II Dillon Zhi October 11, 2015 1 Introduction Some polynomials take integer values p(x) for all integers x. The obvious examples are the ones where

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

Chapter 11 - Sequences and Series

Chapter 11 - Sequences and Series Calculus and Analytic Geometry II Chapter - Sequences and Series. Sequences Definition. A sequence is a list of numbers written in a definite order, We call a n the general term of the sequence. {a, a

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

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

Fast Fourier Transform

Fast Fourier Transform Why Fourier Transform? Fast Fourier Transform Jordi Cortadella and Jordi Petit Department of Computer Science Polynomials: coefficient representation Divide & Conquer Dept. CS, UPC Polynomials: point-value

More information

Divide and Conquer. Arash Rafiey. 27 October, 2016

Divide and Conquer. Arash Rafiey. 27 October, 2016 27 October, 2016 Divide the problem into a number of subproblems Divide the problem into a number of subproblems Conquer the subproblems by solving them recursively or if they are small, there must be

More information

Fall 2016 Test 1 with Solutions

Fall 2016 Test 1 with Solutions CS3510 Design & Analysis of Algorithms Fall 16 Section B Fall 2016 Test 1 with Solutions Instructor: Richard Peng In class, Friday, Sep 9, 2016 Do not open this quiz booklet until you are directed to do

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

Data Structures and Algorithms Running time and growth functions January 18, 2018

Data Structures and Algorithms Running time and growth functions January 18, 2018 Data Structures and Algorithms Running time and growth functions January 18, 2018 Measuring Running Time of Algorithms One way to measure the running time of an algorithm is to implement it and then study

More information

PRIME NUMBERS YANKI LEKILI

PRIME NUMBERS YANKI LEKILI PRIME NUMBERS YANKI LEKILI We denote by N the set of natural numbers: 1,2,..., These are constructed using Peano axioms. We will not get into the philosophical questions related to this and simply assume

More information

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0 Asymptotic Notation Asymptotic notation deals with the behaviour of a function in the limit, that is, for sufficiently large values of its parameter. Often, when analysing the run time of an algorithm,

More information

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms.

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms. Solving recurrences Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms Example: Merge-Sort(A, p, r) 1: if p < r then 2: q (p + r)/2 3: Merge-Sort(A,

More information

Show Your Work! Point values are in square brackets. There are 35 points possible. Some facts about sets are on the last page.

Show Your Work! Point values are in square brackets. There are 35 points possible. Some facts about sets are on the last page. Formal Methods Name: Key Midterm 2, Spring, 2007 Show Your Work! Point values are in square brackets. There are 35 points possible. Some facts about sets are on the last page.. Determine whether each of

More information

Lecture 7: More Arithmetic and Fun With Primes

Lecture 7: More Arithmetic and Fun With Primes IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 7: More Arithmetic and Fun With Primes David Mix Barrington and Alexis Maciel July

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

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

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009 CPSC 320 (Intermediate Algorithm Design and Analysis). Summer 2009. Instructor: Dr. Lior Malka Final Examination, July 24th, 2009 Student ID: INSTRUCTIONS: There are 6 questions printed on pages 1 7. Exam

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

Chapter 1 Divide and Conquer Polynomial Multiplication Algorithm Theory WS 2015/16 Fabian Kuhn

Chapter 1 Divide and Conquer Polynomial Multiplication Algorithm Theory WS 2015/16 Fabian Kuhn Chapter 1 Divide and Conquer Polynomial Multiplication Algorithm Theory WS 2015/16 Fabian Kuhn Formulation of the D&C principle Divide-and-conquer method for solving a problem instance of size n: 1. Divide

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 10, 2018 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. 1 /

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 14, 2019 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. COMP

More information

Fast Convolution; Strassen s Method

Fast Convolution; Strassen s Method Fast Convolution; Strassen s Method 1 Fast Convolution reduction to subquadratic time polynomial evaluation at complex roots of unity interpolation via evaluation at complex roots of unity 2 The Master

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

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2 1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 5 Recurrences, Part 2 Running time of algorithms In computer science,

More information

Contribution of Problems

Contribution of Problems Exam topics 1. Basic structures: sets, lists, functions (a) Sets { }: write all elements, or define by condition (b) Set operations: A B, A B, A\B, A c (c) Lists ( ): Cartesian product A B (d) Functions

More information

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

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

MATH 408N PRACTICE MIDTERM 1

MATH 408N PRACTICE MIDTERM 1 02/0/202 Bormashenko MATH 408N PRACTICE MIDTERM Show your work for all the problems. Good luck! () (a) [5 pts] Solve for x if 2 x+ = 4 x Name: TA session: Writing everything as a power of 2, 2 x+ = (2

More information

Lecture 11 - Basic Number Theory.

Lecture 11 - Basic Number Theory. Lecture 11 - Basic Number Theory. Boaz Barak October 20, 2005 Divisibility and primes Unless mentioned otherwise throughout this lecture all numbers are non-negative integers. We say that a divides b,

More information

Compare the growth rate of functions

Compare the growth rate of functions Compare the growth rate of functions We have two algorithms A 1 and A 2 for solving the same problem, with runtime functions T 1 (n) and T 2 (n), respectively. Which algorithm is more efficient? We compare

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

Solutions to Homework Assignment 2

Solutions to Homework Assignment 2 Solutions to Homework Assignment Real Analysis I February, 03 Notes: (a) Be aware that there maybe some typos in the solutions. If you find any, please let me know. (b) As is usual in proofs, most problems

More information

Main topics for the First Midterm Exam

Main topics for the First Midterm Exam Main topics for the First Midterm Exam The final will cover Sections.-.0, 2.-2.5, and 4.. This is roughly the material from first three homeworks and three quizzes, in addition to the lecture on Monday,

More information

REVIEW FOR THIRD 3200 MIDTERM

REVIEW FOR THIRD 3200 MIDTERM REVIEW FOR THIRD 3200 MIDTERM PETE L. CLARK 1) Show that for all integers n 2 we have 1 3 +... + (n 1) 3 < 1 n < 1 3 +... + n 3. Solution: We go by induction on n. Base Case (n = 2): We have (2 1) 3 =

More information

Homework 1 Solutions

Homework 1 Solutions CS3510 Design & Analysis of Algorithms Section A Homework 1 Solutions Released 4pm Friday Sep 8, 2017 This homework has a total of 4 problems on 4 pages. Solutions should be submitted to GradeScope before

More information

Convergence of sequences and series

Convergence of sequences and series Convergence of sequences and series A sequence f is a map from N the positive integers to a set. We often write the map outputs as f n rather than f(n). Often we just list the outputs in order and leave

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

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!! CSCE 222 Discrete Structures for Computing Review for Exam 2 Dr. Hyunyoung Lee 1 Strategy for Exam Preparation - Start studying now (unless have already started) - Study class notes (lecture slides and

More information

MATH 115, SUMMER 2012 LECTURE 12

MATH 115, SUMMER 2012 LECTURE 12 MATH 115, SUMMER 2012 LECTURE 12 JAMES MCIVOR - last time - we used hensel s lemma to go from roots of polynomial equations mod p to roots mod p 2, mod p 3, etc. - from there we can use CRT to construct

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms Taking Stock IE170: Algorithms in Systems Engineering: Lecture 3 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 19, 2007 Last Time Lots of funky math Playing

More information

PUTNAM PROBLEMS SEQUENCES, SERIES AND RECURRENCES. Notes

PUTNAM PROBLEMS SEQUENCES, SERIES AND RECURRENCES. Notes PUTNAM PROBLEMS SEQUENCES, SERIES AND RECURRENCES Notes. x n+ = ax n has the general solution x n = x a n. 2. x n+ = x n + b has the general solution x n = x + (n )b. 3. x n+ = ax n + b (with a ) can be

More information

CSCI 3110 Assignment 6 Solutions

CSCI 3110 Assignment 6 Solutions CSCI 3110 Assignment 6 Solutions December 5, 2012 2.4 (4 pts) Suppose you are choosing between the following three algorithms: 1. Algorithm A solves problems by dividing them into five subproblems of half

More information

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Copyright c 2015 Andrew Klapper. All rights reserved. 1. For the functions satisfying the following three recurrences, determine which is the

More information

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map

More information

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Lecture 2 More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Announcements Assignment #1 is posted online It is directly related to MCSS which we will be talking about today or Monday. There are

More information

Problem Set 1 Solutions

Problem Set 1 Solutions Introduction to Algorithms September 24, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Piotr Indyk and Charles E. Leiserson Handout 7 Problem Set 1 Solutions Exercise 1-1. Do Exercise

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 6, 2012 CPSC 467b, Lecture 9 1/53 Euler s Theorem Generating RSA Modulus Finding primes by guess and check Density of

More information

Growth of Functions (CLRS 2.3,3)

Growth of Functions (CLRS 2.3,3) Growth of Functions (CLRS 2.3,3) 1 Review Last time we discussed running time of algorithms and introduced the RAM model of computation. Best-case running time: the shortest running time for any input

More information

CSE548, AMS542: Analysis of Algorithms, Spring 2014 Date: May 12. Final In-Class Exam. ( 2:35 PM 3:50 PM : 75 Minutes )

CSE548, AMS542: Analysis of Algorithms, Spring 2014 Date: May 12. Final In-Class Exam. ( 2:35 PM 3:50 PM : 75 Minutes ) CSE548, AMS54: Analysis of Algorithms, Spring 014 Date: May 1 Final In-Class Exam ( :35 PM 3:50 PM : 75 Minutes ) This exam will account for either 15% or 30% of your overall grade depending on your relative

More information

Discrete Mathematics and Probability Theory Summer 2015 Chung-Wei Lin Midterm 1

Discrete Mathematics and Probability Theory Summer 2015 Chung-Wei Lin Midterm 1 CS 70 Discrete Mathematics and Probability Theory Summer 2015 Chung-Wei Lin Midterm 1 PRINT Your Name:, last) first) SIGN Your Name: PRINT Your Student ID: CIRCLE your exam room: 2050 VLSB 10 EVANS OTHER

More information

Chapter 5 Divide and Conquer

Chapter 5 Divide and Conquer CMPT 705: Design and Analysis of Algorithms Spring 008 Chapter 5 Divide and Conquer Lecturer: Binay Bhattacharya Scribe: Chris Nell 5.1 Introduction Given a problem P with input size n, P (n), we define

More information

MATH 115, SUMMER 2012 LECTURE 4 THURSDAY, JUNE 21ST

MATH 115, SUMMER 2012 LECTURE 4 THURSDAY, JUNE 21ST MATH 115, SUMMER 2012 LECTURE 4 THURSDAY, JUNE 21ST JAMES MCIVOR Today we enter Chapter 2, which is the heart of this subject. Before starting, recall that last time we saw the integers have unique factorization

More information

Algorithms and data structures

Algorithms and data structures Algorithms and data structures Amin Coja-Oghlan LFCS Complex numbers Roots of polynomials A polynomial of degree d is a function of the form p(x) = d a i x i with a d 0. i=0 There are at most d numbers

More information

Lecture 3: Big-O and Big-Θ

Lecture 3: Big-O and Big-Θ Lecture 3: Big-O and Big-Θ COSC4: Algorithms and Data Structures Brendan McCane Department of Computer Science, University of Otago Landmark functions We saw that the amount of work done by Insertion Sort,

More information

5.4 Continuity: Preliminary Notions

5.4 Continuity: Preliminary Notions 5.4. CONTINUITY: PRELIMINARY NOTIONS 181 5.4 Continuity: Preliminary Notions 5.4.1 Definitions The American Heritage Dictionary of the English Language defines continuity as an uninterrupted succession,

More information

Computational Complexity - Pseudocode and Recursions

Computational Complexity - Pseudocode and Recursions Computational Complexity - Pseudocode and Recursions Nicholas Mainardi 1 Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it June 6, 2018 1 Partly Based on Alessandro

More information

Taylor and Maclaurin Series. Copyright Cengage Learning. All rights reserved.

Taylor and Maclaurin Series. Copyright Cengage Learning. All rights reserved. 11.10 Taylor and Maclaurin Series Copyright Cengage Learning. All rights reserved. We start by supposing that f is any function that can be represented by a power series f(x)= c 0 +c 1 (x a)+c 2 (x a)

More information

Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions

Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions Math 111, Introduction to the Calculus, Fall 2011 Midterm I Practice Exam 1 Solutions For each question, there is a model solution (showing you the level of detail I expect on the exam) and then below

More information

C241 Homework Assignment 8

C241 Homework Assignment 8 C241 Homework Assignment 8 1. Estimate the performance of the Bubble Sort program for i from 1 to N 1 by 1 do for j from 1 to i 1 by 1 do if A[j ] A[j + 1] then skip; else t := A[j ] ; A[j ] := A[j + 1]

More information

1 Review of complex numbers

1 Review of complex numbers 1 Review of complex numbers 1.1 Complex numbers: algebra The set C of complex numbers is formed by adding a square root i of 1 to the set of real numbers: i = 1. Every complex number can be written uniquely

More information

The Growth of Functions and Big-O Notation

The Growth of Functions and Big-O Notation The Growth of Functions and Big-O Notation Big-O Notation Big-O notation allows us to describe the aymptotic growth of a function without concern for i) constant multiplicative factors, and ii) lower-order

More information

Chapter 8. Infinite Series

Chapter 8. Infinite Series 8.4 Series of Nonnegative Terms Chapter 8. Infinite Series 8.4 Series of Nonnegative Terms Note. Given a series we have two questions:. Does the series converge? 2. If it converges, what is its sum? Corollary

More information

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note

More information

Math 391: Midterm 1.0 Spring 2016

Math 391: Midterm 1.0 Spring 2016 Math 391: Midterm 1.0 Spring 2016 James Skon skonjp@kenyon.edu Test date: October 5 Submission Instructions: Give all your assumptions. Show all your work. Be as complete as possible. Grading Problem 1

More information

COMP 9024, Class notes, 11s2, Class 1

COMP 9024, Class notes, 11s2, Class 1 COMP 90, Class notes, 11s, Class 1 John Plaice Sun Jul 31 1::5 EST 011 In this course, you will need to know a bit of mathematics. We cover in today s lecture the basics. Some of this material is covered

More information

Lecture 7: Indeterminate forms; L Hôpitals rule; Relative rates of growth. If we try to simply substitute x = 1 into the expression, we get

Lecture 7: Indeterminate forms; L Hôpitals rule; Relative rates of growth. If we try to simply substitute x = 1 into the expression, we get Lecture 7: Indeterminate forms; L Hôpitals rule; Relative rates of growth 1. Indeterminate Forms. Eample 1: Consider the it 1 1 1. If we try to simply substitute = 1 into the epression, we get. This is

More information

CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication

CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication Integer multiplication Say we have 5 baskets with 8 apples in each How do we determine how many apples we have? Count them all? That would take

More information

In other words, we are interested in what is happening to the y values as we get really large x values and as we get really small x values.

In other words, we are interested in what is happening to the y values as we get really large x values and as we get really small x values. Polynomial functions: End behavior Solutions NAME: In this lab, we are looking at the end behavior of polynomial graphs, i.e. what is happening to the y values at the (left and right) ends of the graph.

More information

This chapter covers asymptotic analysis of function growth and big-o notation.

This chapter covers asymptotic analysis of function growth and big-o notation. Chapter 14 Big-O This chapter covers asymptotic analysis of function growth and big-o notation. 14.1 Running times of programs An important aspect of designing a computer programs is figuring out how well

More information

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5 CS 70 Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes wish to work over a

More information

Math 414, Fall 2016, Test I

Math 414, Fall 2016, Test I Math 414, Fall 2016, Test I Dr. Holmes September 23, 2016 The test begins at 10:30 am and ends officially at 11:45 am: what will actually happen at 11:45 is that I will give a five minute warning. The

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

CSE548, AMS542: Analysis of Algorithms, Fall 2015 Date: October 12. In-Class Midterm. ( 1:05 PM 2:20 PM : 75 Minutes )

CSE548, AMS542: Analysis of Algorithms, Fall 2015 Date: October 12. In-Class Midterm. ( 1:05 PM 2:20 PM : 75 Minutes ) CSE548, AMS542: Analysis of Algorithms, Fall 2015 Date: October 12 In-Class Midterm ( 1:05 PM 2:20 PM : 75 Minutes ) This exam will account for either 15% or 30% of your overall grade depending on your

More information

Problem Set 2 Solutions

Problem Set 2 Solutions Introduction to Algorithms October 1, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Piotr Indyk and Charles E. Leiserson Handout 9 Problem Set 2 Solutions Reading: Chapters 5-9,

More information

Announcements. CompSci 230 Discrete Math for Computer Science. The Growth of Functions. Section 3.2

Announcements. CompSci 230 Discrete Math for Computer Science. The Growth of Functions. Section 3.2 CompSci 230 Discrete Math for Computer Science Announcements Read Chap. 3.1-3.3 No recitation Friday, Oct 11 or Mon Oct 14 October 8, 2013 Prof. Rodger Section 3.2 Big-O Notation Big-O Estimates for Important

More information

Solutions to Practice Final

Solutions to Practice Final s to Practice Final 1. (a) What is φ(0 100 ) where φ is Euler s φ-function? (b) Find an integer x such that 140x 1 (mod 01). Hint: gcd(140, 01) = 7. (a) φ(0 100 ) = φ(4 100 5 100 ) = φ( 00 5 100 ) = (

More information

ALGEBRA I CCR MATH STANDARDS

ALGEBRA I CCR MATH STANDARDS RELATIONSHIPS BETWEEN QUANTITIES AND REASONING WITH EQUATIONS M.A1HS.1 M.A1HS.2 M.A1HS.3 M.A1HS.4 M.A1HS.5 M.A1HS.6 M.A1HS.7 M.A1HS.8 M.A1HS.9 M.A1HS.10 Reason quantitatively and use units to solve problems.

More information

Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201

Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201 Divide and Conquer: Polynomial Multiplication Version of October 7, 2014 Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201 Outline Outline: Introduction The polynomial multiplication

More information

Simplifying Rational Expressions and Functions

Simplifying Rational Expressions and Functions Department of Mathematics Grossmont College October 15, 2012 Recall: The Number Types Definition The set of whole numbers, ={0, 1, 2, 3, 4,...} is the set of natural numbers unioned with zero, written

More information

MAS114: Solutions to Exercises

MAS114: Solutions to Exercises MAS114: s to Exercises Up to week 8 Note that the challenge problems are intended to be difficult! Doing any of them is an achievement. Please hand them in on a separate piece of paper if you attempt them.

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

Multiplying huge integers using Fourier transforms

Multiplying huge integers using Fourier transforms Fourier transforms October 25, 2007 820348901038490238478324 1739423249728934932894??? integers occurs in many fields of Computational Science: Cryptography Number theory... Traditional approaches to

More information

Asymptotic Analysis 1

Asymptotic Analysis 1 Asymptotic Analysis 1 Last week, we discussed how to present algorithms using pseudocode. For example, we looked at an algorithm for singing the annoying song 99 Bottles of Beer on the Wall for arbitrary

More information

CS 151 Complexity Theory Spring Solution Set 5

CS 151 Complexity Theory Spring Solution Set 5 CS 151 Complexity Theory Spring 2017 Solution Set 5 Posted: May 17 Chris Umans 1. We are given a Boolean circuit C on n variables x 1, x 2,..., x n with m, and gates. Our 3-CNF formula will have m auxiliary

More information

CSE 373: Data Structures and Algorithms. Asymptotic Analysis. Autumn Shrirang (Shri) Mare

CSE 373: Data Structures and Algorithms. Asymptotic Analysis. Autumn Shrirang (Shri) Mare CSE 373: Data Structures and Algorithms Asymptotic Analysis Autumn 2018 Shrirang (Shri) Mare shri@cs.washington.edu Thanks to Kasey Champion, Ben Jones, Adam Blank, Michael Lee, Evan McCarty, Robbie Weber,

More information

8. Limit Laws. lim(f g)(x) = lim f(x) lim g(x), (x) = lim x a f(x) g lim x a g(x)

8. Limit Laws. lim(f g)(x) = lim f(x) lim g(x), (x) = lim x a f(x) g lim x a g(x) 8. Limit Laws 8.1. Basic Limit Laws. If f and g are two functions and we know the it of each of them at a given point a, then we can easily compute the it at a of their sum, difference, product, constant

More information

Chapter 1A -- Real Numbers. iff. Math Symbols: Sets of Numbers

Chapter 1A -- Real Numbers. iff. Math Symbols: Sets of Numbers Fry Texas A&M University! Fall 2016! Math 150 Notes! Section 1A! Page 1 Chapter 1A -- Real Numbers Math Symbols: iff or Example: Let A = {2, 4, 6, 8, 10, 12, 14, 16,...} and let B = {3, 6, 9, 12, 15, 18,

More information

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018 CS 61B More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018 Here is a review of some formulas that you will find useful when doing asymptotic analysis. ˆ N i=1 i = 1 + 2 + 3 + 4 + + N = N(N+1)

More information

CMPSCI 311: Introduction to Algorithms Second Midterm Exam

CMPSCI 311: Introduction to Algorithms Second Midterm Exam CMPSCI 311: Introduction to Algorithms Second Midterm Exam April 11, 2018. Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more

More information

Factoring Algorithms Pollard s p 1 Method. This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors.

Factoring Algorithms Pollard s p 1 Method. This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors. Factoring Algorithms Pollard s p 1 Method This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors. Input: n (to factor) and a limit B Output: a proper factor of

More information

Part 2 Continuous functions and their properties

Part 2 Continuous functions and their properties Part 2 Continuous functions and their properties 2.1 Definition Definition A function f is continuous at a R if, and only if, that is lim f (x) = f (a), x a ε > 0, δ > 0, x, x a < δ f (x) f (a) < ε. Notice

More information