# Lecture 2: Analysis of Algorithms (CS )

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Lecture 2: Analysis of Algorithms (CS ) Amarda Shehu September 03 & 10, 2014

2 1 Outline of Today s Class 2 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math 3 4 Average-case Analysis Average-case Analysis of Insertion Sort

3 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Big-Oh: An Asymptotic Upper Bound Definition A function g(n) O(f (n)) if constants c > 0 and n 0 s.t g(n) c f (n) n n 0. Note: O(f (n)) denotes a set. Graphical Illustration little-oh: Tight Asymptotic Upper Bound g(n) o(f (n)) when the upper bound holds for all constants c > 0. Alternative definition: lim n g(n) f (n) = 0

4 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Big-Omega: An Asymptotic Lower Bound Definition A function g(n) Ω(f (n)) if constants c > 0 and n 0 s.t g(n) c f (n) n n 0. Note: Ω(f (n)) denotes a set. Graphical Illustration little-omega: Tight Asymptotic Lower Bound g(n) ω(f (n)) when the lower bound holds for all constants c > 0. Alternative definition: lim n g(n) f (n) =

5 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Theta: Asymptotic Upper and Lower Bounds Definition A function g(n) Θ(f (n)) if g(n) O(f (n)) and g(n) Ω(f (n)). Alternatively, g(n) Θ(f (n)) if positive constants c 1, c 2 and n 0 s.t. c 1 f (n) g(n) c 2 f (n) n n 0. Graphical Illustration Alternative Definition g(n) θ(f (n)) when lim n g(n) f (n) = O(1)

6 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Techniques for Bounding Functions When bounding functions 1 Go back to definitions of O, Ω, θ 2 Know when the notations do not apply: e.g., in cases of periodic functions like sin(n) 3 Find limits when n 1 Simple transformations: e.g., lim n (n)/n 2 L Hospital s Rule: e.g., lg(n) O( (n)) 3 Combinaton of both: e.g., n! ω(2 n ) 4 Recall techniques to evaluate derivatives: e.g., d dx (x x ) =?

7 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Techniques for Bounding Summations When bounding Summations 1 Obtain answer for series (A.1) or derive it: n 1 i=0 (a 0 + id) = (n+1) (a0+an) 2 n 2 i=0 ai = an+1 1 a 1 for a > 1 If a i+1 a i r, sum over series n i=1 a0r i n 3 i=0 i 2i = (n 1) 2 n Guess the answer and prove by induction 3 Bound each of the terms: e.g., n i=1 1 O(lnn) k 2 4 Split the summation: e.g. k=0 k2 (A.2) 2 k 5 Bound by integral (recall techniques to evaluate integrals) 1 2 n i=1 1 i 2 n i=1 O(1) lg(i) θ(n lnn)

8 Big-Oh, Big-Omega, Theta Techniques for Finding Asymptotic Relationships Some more Fun with Math Flex your Muscles Moderate to Difficult Exercises 1 n i=0 ai O((n + 1) a n ) 2 lg k n o(n ɛ ), ɛ > 0, k 1 3 n k o(c n ), c > 1, k 1 4 Is lgn! polynomially bounded? 5 Is lglgn! polynomially bounded? Figure : The Koch snowflake illustrates the geometric series ar i with a = 1/3 and r = 4/9. Summation gives the area of this snowflake as 8/5 of the blue triangle. c wikipedia.

9 What is a Recurrence? A recurrence is an equation of inequality that describes a function in terms of its value on smaller inputs Example: T (n) of Mergesort is described in terms of T (n/2) Recurrences have boundary conditions (bottom out) Example: T (n) = c when n = 1 1 Iteration or expansion method 2 Recursion-tree method 3 Substitution method 4 5 Generating Functions

10 Outline of Today s Class Expand T (n) = 2T (n/2) + cn iterate down to boundary condition T (n) = 2T (n/2) + cn = 2 [2T (n/4) + c n 2 ] + cn = 4 [2T (n/8) + c n 4 ] + 2cn = 8 T (n/8) + 3cn = 2 3 T (n/2 3 ) + 3cn =... do you see the pattern? = 2 k T (n/2 k ) + kcn Since the recursion bottoms out at n = 1, k = lg(n). So: T (n) = n T (1) + lg(n) cn = cn + cn lg(n) θ(n lgn) Try to solve T (n) = T (n 1) + n, where T (1) = 1. Try to solve T (n) = 2T (n/2) + n, where T (1) = 1.

11 Build recursion tree for T (n) = 2T (n/2) + c n:

12 Example of Solve T (n) = T (n/4) + T (n/2) + n 2 :

13 Substitution (Induction) Method Guess that T (n) = 2T ( n 2 ) + n O(n + n lgn), where T (1) = 1. Then use induction to prove that the guess is correct. 1 Base Case: The boundary condition states that T (1) = 1. The guess states that T (1) O(1 + 1 lg1). Since, lg1 = 1 and 1 O(1), the guess is correct. 2 Inductive Step: Assuming that T ( n 2 ) O( n 2 + n 2 lg(n 2 )), we have to show that the guess holds for T (n): T (n) = 2T ( n 2 ) + n 2[c ( n 2 + n 2 lg(n 2 ))] + n, where c > 0 = c n + c n lgn cn + n = c n lgn + n Easy to show that c n lgn + n O(n + n lgn)

14 Outline of Today s Class Theorem: Let a 1 and b > 1 be constants, let f (n) be a function, and let T (n) be defined on the nonnegative integers by the recurrence T (n) = a T (n/b) + f (n), where n/b can mean n/b or n/b. 1 If f (n) O(n log ba ɛ ) for some constant ɛ > 0, then T (n) θ(n log ba ) 2 If f (n) θ(n log ba ), then T (n) θ(n log ba lgn) 3 If f (n) Ω(n log ba+ɛ ) for some constant ɛ > 0, and if a f (n/b) cf (n) for some constant c < 1 and all sufficiently large n, then T (n) θ(f (n)) Examples: T (n) = 9T (n/3) + n, T (n) = T ( 2n 3 ) + 1, T (n) = 3T ( n 4 ) + nlgn, T (n) = 2T ( n 2 ) + nlgn, T (n) = n T 2 ( n 2 ).

15 Idea Behind : Case 1.

16 Idea Behind : Case 1. Figure : The weight increases geometrically from the root to the leaves. The leaves hold a constant fraction of the total weight. T (n) θ(n log ba ).

17 Idea Behind : Case 2.

18 Idea Behind : Case 3.

19 One can use generating functions and characteristic equations to solve recurrences. This is a topic beyond the scope of this class. However, a simple example on the Fibonacci recurrence showcases the power of this technique for solving recurrences. Let us associate with the sequence {a n } the generating function a(x) = n=0 a nx n. In this way, the recurrence relation for {a n } can be interpreted as an equation for a(x). Example: Find the generating function for Fibonacci sequence and derive a closed form expression for the n th Fibonacci number.

20 Generating Function for Fibonacci Sequence Solution: Let F (x) = n=0 f nx n be the generating function for the Fibonacci sequence. Since the sequence satisfies the recurrence f n = f n 1 + f n 2, an explicit form for F (x) when n 2 as follows: f n = f n 1 + f n 2 f n x n = f n 1 x n + f n 2 x n n=2 f nx n = n=2 f n 1x n + n=2 f n 2x n n=2 f nx n = x n=1 f nx n + x 2 n=0 f nx n So: F (x) f 0 xf 1 = x(f (x) f 0 ) + x 2 F (x) F (x)(1 x x 2 ) = f 0 + x(f 1 f 0 ) = x x F (x) = 1 x x 2

21 Closed Form Expression for Fibonacci Sequence To get a closed form expression for f n, get a closed form expression for the coefficient of x n in the expansion of the generating function. This requires decomposing into partial fractions. 1 1 x x 2 = (1 x 5x 2 )2 ( 2 )2 = (1 x 5x 2 2 )(1 x 5x ) Let s write the above generally as 1 x x 2 = (1 bx)(1 cx), where b = (1 + 5)/2 and c = (1 5)/2. From this, then F (x) = 1/[(1 bx) (1 cx)] =...1/ 5 n 0 (bn+1 c n+1 )x n. So, for all n 0: f n = 1 [( 1 + (5) ) n+1 ( 1 (5) ) n+1 ] (5) 2 2

22 Average-case Analysis Average-case Analysis of Insertion Sort What does Mean refers to the use of probability theory in the analysis of algorithms It is often useful to to analyze the running time of an algorithm To perform a probabilistic analysis, we have to make assumptions on the distribution of inputs After such assumption, we compute an expected running time that is computed over the distribution of all possible inputs In problems where it is not possible to describe an input distribution, probabilistic analysis is not applicable

23 Average-case Analysis Average-case Analysis of Insertion Sort Some Basic Probability Given a sample space S and an event A (which takes values from S), the indicator random variable I(A) associated with the event A is defined as: { 1 if A occurs I (A) = 0 if A does not occur Question: Can you determine the expected number of heads obtained when flipping a fair coin? Sample space S = {H, T }, where H and T refer to Head or Tail. The event A = H The indicator random variable: X H = I (H) = { 1 if H occurs 0 if T occurs

24 Average-case Analysis Average-case Analysis of Insertion Sort Simple Example The expected number of H s from one flip of the coin is the expected value of the indicator random variable X H : E[X H ] = E[I (H)] = 1 P(H) + 0 P(T ) = 1 (1/2) + 0 (1/2) = 1/2 Expected number of H s from one flip of a fair coin is 1/2. Indicator random variables are useful to analyze situations in which one performs repeated random trials (Bernoulli trials). Q: What is the expected number of H s in n flips of a fair coin? Let X i = I {the i th flip results in H} and X = n i=1 X i the total number of H s in n flips. Then: Then: E[X ] = E[ n i=1 X i] = n i=1 E[X i] = n i=1 1/2 = n/2

25 Average-case Analysis Average-case Analysis of Insertion Sort Probability Analysis for Average Case Performance Recall that the worst-case running time T (n) of an algorithm refers to the maximum time of the algorithm on any input of size n. The is also known as the usual case. The best-case T (n) is when a slow algorithm cheats by working fast on some particular input. This is also known as the bogus case. The average-case T (n) refers to the expected time of the algorithm over all inputs of size n. This is known as the sometimes case. Average-case analysis needs assumption of statistical distribution of inputs Employ probabilistic analysis to show that the average-case T (n) of insertion sort is θ(n 2 )

26 Average-case Analysis Average-case Analysis of Insertion Sort Average-case Analysis of Insertion Sort Recall that T (n) of insertion sort is n j=2 f (n), where f (n) sums the execution time of the inner while loop. Ignoring the machine-dependent constants, f (n) measures the number of times the elements in A[1...j 1] have to be moved right to open up the correct position where to insert the value in A[j]. Hence, f (n) records the expected number of moves so A[j] is in correct position. Question: What is f (n)?

27 Average-case Analysis Average-case Analysis of Insertion Sort Average-case Analysis of Insertion Sort Let k denote the total number of moves to the right and k i denote the number of moves when A[i] > A j. Then: E(k) = j 1 i=1 Prob.(A[i] > A[j]) k i = j 1 i=1 1 j (j i) = 1 j j 1 i=1 (j i) = 1 j [ j 1 i=1 j j 1 i=1 i] = 1 j [j j j (j 1) 2 ] = j j 1 2 = 2j j+1 2 = j+1 2 So, T (n) = n j=2 j+1 2 = (n+4) (n 1) 4 θ(n 2 )

### Today s Outline. Exercise. Binary Search Analysis. Linear Search Analysis. Asymptotic Analysis. Analyzing Code. Announcements. Asymptotic Analysis

Today s Outline Announcements Assignment #1 due Thurs, Oct 7 at 11:45pm Asymptotic Analysis Asymptotic Analysis CSE 7 Data Structures & Algorithms Ruth Anderson Autumn 2010 Exercise Analyzing Code bool

### Divide-and-Conquer Algorithms Part Four

Divide-and-Conquer Algorithms Part Four Announcements Problem Set 2 due right now. Can submit by Monday at 2:15PM using one late period. Problem Set 3 out, due July 22. Play around with divide-and-conquer

### Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally

Recurrence Relations Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally modeled by recurrence relations. A recurrence relation is an equation which

### Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4

Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4 I. Algorithm Design and Divide-and-Conquer There are various strategies we

### the recursion-tree method

the recursion- method recurrence into a 1 recurrence into a 2 MCS 360 Lecture 39 Introduction to Data Structures Jan Verschelde, 22 November 2010 recurrence into a The for consists of two steps: 1 Guess

### Polynomials and the Fast Fourier Transform (FFT) Battle Plan

Polynomials and the Fast Fourier Transform (FFT) Algorithm Design and Analysis (Wee 7) 1 Polynomials Battle Plan Algorithms to add, multiply and evaluate polynomials Coefficient and point-value representation

### Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Recursion Slides by Christopher M Bourke Instructor: Berthe Y Choueiry Fall 007 Computer Science & Engineering 35 Introduction to Discrete Mathematics Sections 71-7 of Rosen cse35@cseunledu Recursive Algorithms

### CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

CSC148 Lecture 8 Algorithm Analysis Binary Search Sorting Algorithm Analysis Recall definition of Big Oh: We say a function f(n) is O(g(n)) if there exists positive constants c,b such that f(n)

### Analysis of Algorithms: The Non-recursive Case

Analysis of Algorithms: The Non-recursive Case Key topics: * Introduction * Generalizing Running Time * Doing a Timing Analysis * Big-Oh Notation * Big-Oh Operations * Analyzing Some Simple Programs -

### Exercises with solutions (1)

Exercises with solutions (). Investigate the relationship between independence and correlation. (a) Two random variables X and Y are said to be correlated if and only if their covariance C XY is not equal

### CS473 - Algorithms I

CS473 - Algorithms I Lecture 4 The Divide-and-Conquer Design Paradigm View in slide-show mode 1 Reminder: Merge Sort Input array A sort this half sort this half Divide Conquer merge two sorted halves Combine

### Series Convergence Tests Math 122 Calculus III D Joyce, Fall 2012

Some series converge, some diverge. Series Convergence Tests Math 22 Calculus III D Joyce, Fall 202 Geometric series. We ve already looked at these. We know when a geometric series converges and what it

### Divide and Conquer. Textbook Reading Chapters 4, 7 & 33.4

Divide d Conquer Textook Reading Chapters 4, 7 & 33.4 Overview Design principle Divide d conquer Proof technique Induction, induction, induction Analysis technique Recurrence relations Prolems Sorting

### CS473 - Algorithms I

CS473 - Algorithms I Lecture 9 Sorting in Linear Time View in slide-show mode 1 How Fast Can We Sort? The algorithms we have seen so far: Based on comparison of elements We only care about the relative

### Format of Divide-and-Conquer algorithms:

CS 360: Data Structures and Algorithms Divide-and-Conquer (part 1) Format of Divide-and-Conquer algorithms: Divide: Split the array or list into smaller pieces Conquer: Solve the same problem recursively

### HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

### Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

### Taylor Polynomials and Taylor Series Math 126

Taylor Polynomials and Taylor Series Math 26 In many problems in science and engineering we have a function f(x) which is too complicated to answer the questions we d like to ask. In this chapter, we will

### Partial Fractions. (x 1)(x 2 + 1)

Partial Fractions Adding rational functions involves finding a common denominator, rewriting each fraction so that it has that denominator, then adding. For example, 3x x 1 3x(x 1) (x + 1)(x 1) + 1(x +

### 2010 Solutions. a + b. a + b 1. (a + b)2 + (b a) 2. (b2 + a 2 ) 2 (a 2 b 2 ) 2

00 Problem If a and b are nonzero real numbers such that a b, compute the value of the expression ( ) ( b a + a a + b b b a + b a ) ( + ) a b b a + b a +. b a a b Answer: 8. Solution: Let s simplify the

### 1 Lecture: Integration of rational functions by decomposition

Lecture: Integration of rational functions by decomposition into partial fractions Recognize and integrate basic rational functions, except when the denominator is a power of an irreducible quadratic.

### Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

### Math 115 Spring 2011 Written Homework 5 Solutions

. Evaluate each series. a) 4 7 0... 55 Math 5 Spring 0 Written Homework 5 Solutions Solution: We note that the associated sequence, 4, 7, 0,..., 55 appears to be an arithmetic sequence. If the sequence

### The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

### Quicksort is a divide-and-conquer sorting algorithm in which division is dynamically carried out (as opposed to static division in Mergesort).

Chapter 7: Quicksort Quicksort is a divide-and-conquer sorting algorithm in which division is dynamically carried out (as opposed to static division in Mergesort). The three steps of Quicksort are as follows:

### Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

Class Overview CSE 326: Data Structures Introduction Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know

### Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm

### Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

Binary Search Trees Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 27 1 Properties of Binary Search Trees 2 Basic BST operations The worst-case time complexity of BST operations

### Mergesort and Quicksort

Mergesort Mergesort and Quicksort Basic plan: Divide array into two halves. Recursively sort each half. Merge two halves to make sorted whole. mergesort mergesort analysis quicksort quicksort analysis

### Lecture 4: Properties of and Rules for

Lecture 4: Properties of and Rules for Asymptotic Big-Oh, Big-Omega, and Big-Theta Notation Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 13 1 Time complexity 2 Big-Oh rules Scaling

### CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

### Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80)

Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80) CS 30, Winter 2016 by Prasad Jayanti 1. (10 points) Here is the famous Monty Hall Puzzle. Suppose you are on a game show, and you

### Lecture 13: Martingales

Lecture 13: Martingales 1. Definition of a Martingale 1.1 Filtrations 1.2 Definition of a martingale and its basic properties 1.3 Sums of independent random variables and related models 1.4 Products of

### Algorithms, Integers

CHAPTER 3 Algorithms, Integers 3.1. Algorithms Consider the following list of instructions to find the maximum of three numbers a, b, c: 1. Assign variable x the value of a. 2. If b > x then assign x the

### Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

### 3. INNER PRODUCT SPACES

. INNER PRODUCT SPACES.. Definition So far we have studied abstract vector spaces. These are a generalisation of the geometric spaces R and R. But these have more structure than just that of a vector space.

### Approximation Algorithms

Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

### CM2202: Scientific Computing and Multimedia Applications General Maths: 2. Algebra - Factorisation

CM2202: Scientific Computing and Multimedia Applications General Maths: 2. Algebra - Factorisation Prof. David Marshall School of Computer Science & Informatics Factorisation Factorisation is a way of

### CS/COE 1501 http://cs.pitt.edu/~bill/1501/

CS/COE 1501 http://cs.pitt.edu/~bill/1501/ Lecture 01 Course Introduction Meta-notes These notes are intended for use by students in CS1501 at the University of Pittsburgh. They are provided free of charge

### Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

### Simplified Analyses of Randomized Algorithms for Searching, Sorting, and Selection

Simplified Analyses of Randomized Algorithms for Searching, Sorting, and Selection i Michael T. Goodrich Roberto Tamassia Dept. of Info. & Computer Science Dept. of Computer Science University of California

### 3.3. Solving Polynomial Equations. Introduction. Prerequisites. Learning Outcomes

Solving Polynomial Equations 3.3 Introduction Linear and quadratic equations, dealt within Sections 3.1 and 3.2, are members of a class of equations, called polynomial equations. These have the general

### SMT 2014 Algebra Test Solutions February 15, 2014

1. Alice and Bob are painting a house. If Alice and Bob do not take any breaks, they will finish painting the house in 20 hours. If, however, Bob stops painting once the house is half-finished, then the

### Math 55: Discrete Mathematics

Math 55: Discrete Mathematics UC Berkeley, Spring 2012 Homework # 9, due Wednesday, April 11 8.1.5 How many ways are there to pay a bill of 17 pesos using a currency with coins of values of 1 peso, 2 pesos,

### 1 Fixed Point Iteration and Contraction Mapping Theorem

1 Fixed Point Iteration and Contraction Mapping Theorem Notation: For two sets A,B we write A B iff x A = x B. So A A is true. Some people use the notation instead. 1.1 Introduction Consider a function

### JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

JUST THE MATHS UNIT NUMBER 1.8 ALGEBRA 8 (Polynomials) by A.J.Hobson 1.8.1 The factor theorem 1.8.2 Application to quadratic and cubic expressions 1.8.3 Cubic equations 1.8.4 Long division of polynomials

### Why? A central concept in Computer Science. Algorithms are ubiquitous.

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include 2 + 5.

PUTNAM TRAINING POLYNOMIALS (Last updated: November 17, 2015) Remark. This is a list of exercises on polynomials. Miguel A. Lerma Exercises 1. Find a polynomial with integral coefficients whose zeros include

### LECTURE 2. Part/ References Topic/Sections Notes/Speaker. 1 Enumeration 1 1.1 Generating functions... 1. Combinatorial. Asst #1 Due FS A.

Wee Date Sections f aculty of science MATH 895-4 Fall 0 Contents 1 Sept 7 I1, I, I3 Symbolic methods I A3/ C Introduction to Prob 4 A sampling 18 IX1 of counting sequences Limit Laws and and generating

### Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

7 Catalan Numbers Thomas A. Dowling, Department of Mathematics, Ohio State Uni- Author: versity. Prerequisites: The prerequisites for this chapter are recursive definitions, basic counting principles,

### 3.6. Partial Fractions. Introduction. Prerequisites. Learning Outcomes

Partial Fractions 3.6 Introduction It is often helpful to break down a complicated algebraic fraction into a sum of simpler fractions. For 4x + 7 example it can be shown that x 2 + 3x + 2 has the same

### Functions and Equations

Centre for Education in Mathematics and Computing Euclid eworkshop # Functions and Equations c 014 UNIVERSITY OF WATERLOO Euclid eworkshop # TOOLKIT Parabolas The quadratic f(x) = ax + bx + c (with a,b,c

### CMPS 102 Solutions to Homework 1

CMPS 0 Solutions to Homework Lindsay Brown, lbrown@soe.ucsc.edu September 9, 005 Problem..- p. 3 For inputs of size n insertion sort runs in 8n steps, while merge sort runs in 64n lg n steps. For which

### Algorithms and Methods for Distributed Storage Networks 9 Analysis of DHT Christian Schindelhauer

Algorithms and Methods for 9 Analysis of DHT Institut für Informatik Wintersemester 2007/08 Distributed Hash-Table (DHT) Hash table does not work efficiently for inserting and deleting Distributed Hash-Table

### Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

### Sequences and Series

Sequences and Series Consider the following sum: 2 + 4 + 8 + 6 + + 2 i + The dots at the end indicate that the sum goes on forever. Does this make sense? Can we assign a numerical value to an infinite

### CS 102: SOLUTIONS TO DIVIDE AND CONQUER ALGORITHMS (ASSGN 4)

CS 10: SOLUTIONS TO DIVIDE AND CONQUER ALGORITHMS (ASSGN 4) Problem 1. a. Consider the modified binary search algorithm so that it splits the input not into two sets of almost-equal sizes, but into three

### Appendix: Solving Recurrences [Fa 10] Wil Wheaton: Embrace the dark side! Sheldon: That s not even from your franchise!

Change is certain. Peace is followed by disturbances; departure of evil men by their return. Such recurrences should not constitute occasions for sadness but realities for awareness, so that one may be

### Mth 95 Module 2 Spring 2014

Mth 95 Module Spring 014 Section 5.3 Polynomials and Polynomial Functions Vocabulary of Polynomials A term is a number, a variable, or a product of numbers and variables raised to powers. Terms in an expression

### is identically equal to x 2 +3x +2

Partial fractions 3.6 Introduction It is often helpful to break down a complicated algebraic fraction into a sum of simpler fractions. 4x+7 For example it can be shown that has the same value as 1 + 3

### Lecture 3: Linear Programming Relaxations and Rounding

Lecture 3: Linear Programming Relaxations and Rounding 1 Approximation Algorithms and Linear Relaxations For the time being, suppose we have a minimization problem. Many times, the problem at hand can

### Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

### Probability Generating Functions

page 39 Chapter 3 Probability Generating Functions 3 Preamble: Generating Functions Generating functions are widely used in mathematics, and play an important role in probability theory Consider a sequence

### The Method of Partial Fractions Math 121 Calculus II Spring 2015

Rational functions. as The Method of Partial Fractions Math 11 Calculus II Spring 015 Recall that a rational function is a quotient of two polynomials such f(x) g(x) = 3x5 + x 3 + 16x x 60. The method

### x if x 0, x if x < 0.

Chapter 3 Sequences In this chapter, we discuss sequences. We say what it means for a sequence to converge, and define the limit of a convergent sequence. We begin with some preliminary results about the

### Sequential Data Structures

Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year

### The Topsy-Turvy World of Continued Fractions [online]

Chapter 47 The Topsy-Turvy World of Continued Fractions [online] The other night, from cares exempt, I slept and what d you think I dreamt? I dreamt that somehow I had come, To dwell in Topsy-Turveydom!

### Appendix F: Mathematical Induction

Appendix F: Mathematical Induction Introduction In this appendix, you will study a form of mathematical proof called mathematical induction. To see the logical need for mathematical induction, take another

### Random variables, probability distributions, binomial random variable

Week 4 lecture notes. WEEK 4 page 1 Random variables, probability distributions, binomial random variable Eample 1 : Consider the eperiment of flipping a fair coin three times. The number of tails that

### Data Structures. Algorithm Performance and Big O Analysis

Data Structures Algorithm Performance and Big O Analysis What s an Algorithm? a clearly specified set of instructions to be followed to solve a problem. In essence: A computer program. In detail: Defined

### CSC 180 H1F Algorithm Runtime Analysis Lecture Notes Fall 2015

1 Introduction These notes introduce basic runtime analysis of algorithms. We would like to be able to tell if a given algorithm is time-efficient, and to be able to compare different algorithms. 2 Linear

20 Selfish Load Balancing Berthold Vöcking Abstract Suppose that a set of weighted tasks shall be assigned to a set of machines with possibly different speeds such that the load is distributed evenly among

### 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

### Mathematical Induction. Lecture 10-11

Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

### 1 Review of Least Squares Solutions to Overdetermined Systems

cs4: introduction to numerical analysis /9/0 Lecture 7: Rectangular Systems and Numerical Integration Instructor: Professor Amos Ron Scribes: Mark Cowlishaw, Nathanael Fillmore Review of Least Squares

### 1.7. Partial Fractions. 1.7.1. Rational Functions and Partial Fractions. A rational function is a quotient of two polynomials: R(x) = P (x) Q(x).

.7. PRTIL FRCTIONS 3.7. Partial Fractions.7.. Rational Functions and Partial Fractions. rational function is a quotient of two polynomials: R(x) = P (x) Q(x). Here we discuss how to integrate rational

### The Running Time of Programs

CHAPTER 3 The Running Time of Programs In Chapter 2, we saw two radically different algorithms for sorting: selection sort and merge sort. There are, in fact, scores of algorithms for sorting. This situation

### Applied Algorithm Design Lecture 5

Applied Algorithm Design Lecture 5 Pietro Michiardi Eurecom Pietro Michiardi (Eurecom) Applied Algorithm Design Lecture 5 1 / 86 Approximation Algorithms Pietro Michiardi (Eurecom) Applied Algorithm Design

### Solutions of Equations in One Variable. Fixed-Point Iteration II

Solutions of Equations in One Variable Fixed-Point Iteration II Numerical Analysis (9th Edition) R L Burden & J D Faires Beamer Presentation Slides prepared by John Carroll Dublin City University c 2011

### Jacobi s four squares identity Martin Klazar

Jacobi s four squares identity Martin Klazar (lecture on the 7-th PhD conference) Ostrava, September 10, 013 C. Jacobi [] in 189 proved that for any integer n 1, r (n) = #{(x 1, x, x 3, x ) Z ( i=1 x i

### Divide And Conquer Algorithms

CSE341T/CSE549T 09/10/2014 Lecture 5 Divide And Conquer Algorithms Recall in last lecture, we looked at one way of parallelizing matrix multiplication. At the end of the lecture, we saw the reduce SUM

### Lecture 4: BK inequality 27th August and 6th September, 2007

CSL866: Percolation and Random Graphs IIT Delhi Amitabha Bagchi Scribe: Arindam Pal Lecture 4: BK inequality 27th August and 6th September, 2007 4. Preliminaries The FKG inequality allows us to lower bound

### BX in ( u, v) basis in two ways. On the one hand, AN = u+

1. Let f(x) = 1 x +1. Find f (6) () (the value of the sixth derivative of the function f(x) at zero). Answer: 7. We expand the given function into a Taylor series at the point x = : f(x) = 1 x + x 4 x

### Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Quiz 1 Quiz 1 Do not open this quiz booklet until you are directed

### General Framework for an Iterative Solution of Ax b. Jacobi s Method

2.6 Iterative Solutions of Linear Systems 143 2.6 Iterative Solutions of Linear Systems Consistent linear systems in real life are solved in one of two ways: by direct calculation (using a matrix factorization,

### Real Roots of Univariate Polynomials with Real Coefficients

Real Roots of Univariate Polynomials with Real Coefficients mostly written by Christina Hewitt March 22, 2012 1 Introduction Polynomial equations are used throughout mathematics. When solving polynomials

### Large induced subgraphs with all degrees odd

Large induced subgraphs with all degrees odd A.D. Scott Department of Pure Mathematics and Mathematical Statistics, University of Cambridge, England Abstract: We prove that every connected graph of order

### Algorithms. Margaret M. Fleck. 18 October 2010

Algorithms Margaret M. Fleck 18 October 2010 These notes cover how to analyze the running time of algorithms (sections 3.1, 3.3, 4.4, and 7.1 of Rosen). 1 Introduction The main reason for studying big-o

### Inner Product Spaces

Math 571 Inner Product Spaces 1. Preliminaries An inner product space is a vector space V along with a function, called an inner product which associates each pair of vectors u, v with a scalar u, v, and

### Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

ECS20 Discrete Mathematics Quarter: Spring 2007 Instructor: John Steinberger Assistant: Sophie Engle (prepared by Sophie Engle) Homework 8 Hints Due Wednesday June 6 th 2007 Section 6.1 #16 What is the

### Corollary. (f є C n+1 [a,b]). Proof: This follows directly from the preceding theorem using the inequality

Corollary For equidistant knots, i.e., u i = a + i (b-a)/n, we obtain with (f є C n+1 [a,b]). Proof: This follows directly from the preceding theorem using the inequality 120202: ESM4A - Numerical Methods

### Algebra Unpacked Content For the new Common Core standards that will be effective in all North Carolina schools in the 2012-13 school year.

This document is designed to help North Carolina educators teach the Common Core (Standard Course of Study). NCDPI staff are continually updating and improving these tools to better serve teachers. Algebra

### Polynomials and Vieta s Formulas

Polynomials and Vieta s Formulas Misha Lavrov ARML Practice 2/9/2014 Review problems 1 If a 0 = 0 and a n = 3a n 1 + 2, find a 100. 2 If b 0 = 0 and b n = n 2 b n 1, find b 100. Review problems 1 If a

### 10.2 Series and Convergence

10.2 Series and Convergence Write sums using sigma notation Find the partial sums of series and determine convergence or divergence of infinite series Find the N th partial sums of geometric series and

### Math 181 Handout 16. Rich Schwartz. March 9, 2010

Math 8 Handout 6 Rich Schwartz March 9, 200 The purpose of this handout is to describe continued fractions and their connection to hyperbolic geometry. The Gauss Map Given any x (0, ) we define γ(x) =

### U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009. Notes on Algebra

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009 Notes on Algebra These notes contain as little theory as possible, and most results are stated without proof. Any introductory

### Near Optimal Solutions

Near Optimal Solutions Many important optimization problems are lacking efficient solutions. NP-Complete problems unlikely to have polynomial time solutions. Good heuristics important for such problems.

### The Euler constant : γ

Numbers, constants and computation 1 The Euler constant : γ Xavier Gourdon and Pascal Sebah April 14, 2004 1 γ = 0.57721566490153286060651209008240243104215933593992... 1 Introduction Euler s Constant