CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)

Similar documents
Recurrence Relations

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

1. By using truth tables prove that, for all statements P and Q, the statement

You may work in pairs or purely individually for this assignment.

Math 155 (Lecture 3)

Analysis of Algorithms. Introduction. Contents

Calculus 2 - D. Yuen Final Exam Review (Version 11/22/2017. Please report any possible typos.)

ECE-S352 Introduction to Digital Signal Processing Lecture 3A Direct Solution of Difference Equations

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Test One (Answer Key)

We are mainly going to be concerned with power series in x, such as. (x)} converges - that is, lims N n

CHAPTER 1 SEQUENCES AND INFINITE SERIES

Chapter 6. Advanced Counting Techniques

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2

Math 475, Problem Set #12: Answers

SNAP Centre Workshop. Basic Algebraic Manipulation

CS / MCS 401 Homework 3 grader solutions

Chapter 4. Fourier Series

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

10.1 Sequences. n term. We will deal a. a n or a n n. ( 1) n ( 1) n 1 2 ( 1) a =, 0 0,,,,, ln n. n an 2. n term.

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis

Zeros of Polynomials

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

Solutions to Final Exam

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

2.4 - Sequences and Series

Exam 2 CMSC 203 Fall 2009 Name SOLUTION KEY Show All Work! 1. (16 points) Circle T if the corresponding statement is True or F if it is False.

Fundamental Theorem of Algebra. Yvonne Lai March 2010

Section 1 of Unit 03 (Pure Mathematics 3) Algebra

Real Variables II Homework Set #5

CHAPTER 5. Theory and Solution Using Matrix Techniques

Ma 4121: Introduction to Lebesgue Integration Solutions to Homework Assignment 5

Linear Differential Equations of Higher Order Basic Theory: Initial-Value Problems d y d y dy

3.2 Properties of Division 3.3 Zeros of Polynomials 3.4 Complex and Rational Zeros of Polynomials

2.4 Sequences, Sequences of Sets

Lecture Notes for CS 313H, Fall 2011

Northwest High School s Algebra 2/Honors Algebra 2 Summer Review Packet

Solution of Linear Constant-Coefficient Difference Equations

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

It is often useful to approximate complicated functions using simpler ones. We consider the task of approximating a function by a polynomial.

PAPER : IIT-JAM 2010

Solutions to Math 347 Practice Problems for the final

Topic 1 2: Sequences and Series. A sequence is an ordered list of numbers, e.g. 1, 2, 4, 8, 16, or

Random Models. Tusheng Zhang. February 14, 2013

SOLUTIONS TO EXAM 3. Solution: Note that this defines two convergent geometric series with respective radii r 1 = 2/5 < 1 and r 2 = 1/5 < 1.

In algebra one spends much time finding common denominators and thus simplifying rational expressions. For example:

1 Generating functions for balls in boxes

Course : Algebraic Combinatorics

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3

f(x) dx as we do. 2x dx x also diverges. Solution: We compute 2x dx lim

The log-behavior of n p(n) and n p(n)/n

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) =

The Discrete Fourier Transform

Ma 530 Infinite Series I

Solutions to Final Exam Review Problems

Advanced Course of Algorithm Design and Analysis

arxiv: v1 [math.fa] 3 Apr 2016

Math 140A Elementary Analysis Homework Questions 1

Symbolic computation 2: Linear recurrences

Algorithm Analysis. Chapter 3

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

Problem Set 1 Solutions

4.3 Growth Rates of Solutions to Recurrences

+ au n+1 + bu n = 0.)

Section A assesses the Units Numerical Analysis 1 and 2 Section B assesses the Unit Mathematics for Applied Mathematics

Summary: CORRELATION & LINEAR REGRESSION. GC. Students are advised to refer to lecture notes for the GC operations to obtain scatter diagram.

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

MIDTERM 3 CALCULUS 2. Monday, December 3, :15 PM to 6:45 PM. Name PRACTICE EXAM SOLUTIONS

n=1 a n is the sequence (s n ) n 1 n=1 a n converges to s. We write a n = s, n=1 n=1 a n

Assignment 5: Solutions

Polynomial and Rational Functions. Polynomial functions and Their Graphs. Polynomial functions and Their Graphs. Examples

Problem. Consider the sequence a j for j N defined by the recurrence a j+1 = 2a j + j for j > 0

ECE 308 Discrete-Time Signals and Systems

Introduction To Discrete Mathematics

A Simplified Binet Formula for k-generalized Fibonacci Numbers

6.3 Testing Series With Positive Terms

Math 132, Fall 2009 Exam 2: Solutions

MA131 - Analysis 1. Workbook 3 Sequences II

4x 2. (n+1) x 3 n+1. = lim. 4x 2 n+1 n3 n. n 4x 2 = lim = 3

CALCULATION OF FIBONACCI VECTORS

Disjoint set (Union-Find)

Definition 4.2. (a) A sequence {x n } in a Banach space X is a basis for X if. unique scalars a n (x) such that x = n. a n (x) x n. (4.

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018)

Regent College Maths Department. Further Pure 1. Proof by Induction

A widely used display of protein shapes is based on the coordinates of the alpha carbons - - C α

subcaptionfont+=small,labelformat=parens,labelsep=space,skip=6pt,list=0,hypcap=0 subcaption ALGEBRAIC COMBINATORICS LECTURE 8 TUESDAY, 2/16/2016

Series III. Chapter Alternating Series

MAS111 Convergence and Continuity

15.081J/6.251J Introduction to Mathematical Programming. Lecture 21: Primal Barrier Interior Point Algorithm

CHAPTER 10 INFINITE SEQUENCES AND SERIES

Properties and Tests of Zeros of Polynomial Functions

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability.

Math 210A Homework 1

Chapter 2. Asymptotic Notation

Physics 116A Solutions to Homework Set #1 Winter Boas, problem Use equation 1.8 to find a fraction describing

MAT1026 Calculus II Basic Convergence Tests for Series

Different kinds of Mathematical Induction

ECE4270 Fundamentals of DSP. Lecture 2 Discrete-Time Signals and Systems & Difference Equations. Overview of Lecture 2. More Discrete-Time Systems

Transcription:

CSI 101 Discrete Structures Witer 01 Prof. Lucia Moura Uiversity of Ottawa Homework Assigmet #4 (100 poits, weight %) Due: Thursday, April, at 1:00pm (i lecture) Program verificatio, Recurrece Relatios 1. Cosider the followig program that computes quotiets ad remaiders: r a; q 0; while r d do begi r r d; q q + 1; ed Use the followig steps i order to verify that the program is correct with respect to the iitial assertio a ad d are positive itegers ad fial assertio q ad r are itegers such that a = dq + r ad 0 r < d. (a) Fid a appropriate loop ivariat that is strog eough to give the fial assertio, ad prove that it is a loop ivariat. (b) Usig part (a) ad other iferece rules for program verificatio, prove the program is partially correct with respect to the iitial ad fial assertios. (c) Complete a proof of correctess by formally provig the termiatio of the loop. (a) We claim that the loop ivariat we eed is the followig propositio p: p = a = qd + r ad r 0. To show that p is a loop ivariat, we must show that: i. p is true before the loop executes. Sice a is a positive iteger ad r a before the loop executes, we have that r 0. Sice q 0 before the loop executes, the qd + r = 0d + a = a. Thus, p is true before the loop executes. ii. If p is true before the loop is executed, the p is true after the loop executes. Assume that p is true before the loop is executed. The, after the loop executes, we have the ew values r = r d ad q = q + 1. We must show that p still holds with regards to these ew values. Sice, by 1

the coditio of the loop, r d, we have that r = r d d d = 0. Furthermore: a = qd+r = qd+r d+d = (qd+d)+(r d) = (q +1)d+(r d) = q d+r. Thus, p is still true after the loop executes. Therefore, p is a loop ivariat. (b) Let S deote the etire program, S 1 deote the two statemets before the while loop, ad S deote the statemets i the while block. If q is the predicate a ad d are positive itegers, ad t is the predicate q ad r are positive itegers such that a = dq + r ad 0 r < d, we show that q{s}t holds. This is equivalet to showig q{s 1 while r d{s }}t holds. We must the show that q{s 1 }p ad (p r d){s }p holds: this is true from the first part, where we showed that p is a loop ivariat. Thus, by the rules of iferece for while loops, we have that p{while r d{s }}(p (r d)). This implies that if the loop termiates, it does so with p true ad r d false, i.e. r < d, ad thus a = qd + r ad 0 r < d, which is precisely t. Thus, this is equivalet to p{while r d{s }}t holds. Sice q{s 1 }p holds, we ca combie these ad have that q{s 1 while r d{s }}t, or q{s}t, as required. (c) We show that the loop termiates evetually. Associate with each iteratio of the loop the value of r. Sice r is, by assumptio, a positive iteger, ad i every iteratio we decrease the value of r by d, the value of r forms a strictly decreasig sequece. Furthermore, sice the loop termiates whe r < d, we have that the value of r is bouded below by 0. Thus, by the well-orderig priciple, the loop must termiate i a fiite umber of iteratios.. (a) Fid the characteristic roots of the liear homogeeous recurrece relatio a = a 1 a. (Note these are complex umbers) (b) Fid the solutio of the recurrece relatio i part (a) with a 0 = 1 ad a 1 =. The relatio has characteristic equatio: r r + = 0. By usig the quadratic equatio, we have that: r = b ± b 4ac a = ± 4 8 Thus, the characteristic roots are 1 + i ad 1 i. This gives that the solutio to the relatio has form: = 1 ± i. a = α(1 + i) + β(1 i)

for some umbers α, β. We use the iitial values to determie α ad β: a 0 = 1 = α + β a 1 = = α(1 + i) + β(1 i) By substitutig β = 1 α ito the secod equatio, we derive: α(1 + i) + (1 α)(1 i) = iα = 1 + i α = 1 + i i = 1 + i i Thus: β = 1 α = 1 1 i Hece, the solutio to the recurrece relatio is: ( ) ( 1 i 1 + i a = (1 + i) + = 1 + i. i i = 1 i. ) (1 i). 3. Fid all solutios of the recurrece relatio a = 7a 1 16a + 1a 3 + 4 with a 0 =, a 1 = 0 ad a =. This is a ohomogeeous recurrece relatio, so we eed to fid the solutio to the associated homogeeous recurrece relatio ad a particular solutio to the origial relatio. The associated homogeeous recurrece relatio is: a (h) This has characteristic equatio: = 7a (h) 1 16a (h) + 1a (h) 3. r 3 7r + 16r 1 = 0 (r ) (r 3) = 0 Thus, the solutio to the homogeeous relatio is: a (h) = α + β + γ3 for some real umbers α, β, γ, which we will fid later via the iitial values after we have the geeral solutio to the full recurrece. We ow eed the particular solutio. We have that: F () = 4 3

This has polyomial part, so the degree of the polyomial part is t = 1. It has expoetial part 4, so s = 4. By S7. Theorem 6, the particular solutio thus has form: = (q + p)4 for some real umbers p, q. We fid the values of p ad q by substitutig the particular solutio ito the origial recurrece relatio: = 7 1 16 + 1 3 + 4 (q + p)4 = 7(q( 1) + p)4 1 16(q( ) + p)4 + 1(q( 3) + p)4 3 + 4 We ow divide the equatio by 4 3 to get: (q + p)4 3 = 7(q( 1) + p)4 16(q( ) + p)4 1 + 1(q( 3) + p) + 4 3. Multiplyig out ad simplifyig gives: (4q 64) + (4p 0q) = 0 = 0 + 0. This ca be separated ito two equatios by settig the coefficiets of the polyomials to be equal: 4q 64 = 0 4p 0q = 0 This has solutio p = 80, q = 16, so the particular solutio is: = (16 80)4. Thus, the format of the geeral solutio to the recurrece relatio is: a = a (h) Usig the iitial values, we have: + = α + β + γ3 + (16 80)4. a 0 = = α + γ 80 a 1 = 0 = α + β + 3γ + ( 64) 4 a = = 4α + 8β + 9γ + ( 48) 16 This gives a system of three liear equatios i three ukows, which has solutio α = 17, β = 39, γ = 61. Hece, the recurrece relatio has solutio: a = 17 + 39 + 61 3 + (16 80)4 = 17 + 39 1 + 61 3 + (16 80)4. 4

4. Cosider the followig recursive procedure to compute the fiboacci umbers: procedure FIB(: o-egative iteger) if = 0 the retur 0 else if = 1 the retur 1 else retur FIB( 1)+FIB( ) (a) Set up a recurrece relatio that couts the umber of times the sum (+) is executed cosiderig all the recursive calls used for iput. (Do t forget to provide iitial coditios as well) (b) Solve the recurrece relatio of part (a). Let a be the umber of sum operatios that are performed i calculatig the th fiboacci umber usig the recursive procedure. If = 0 or = 1, o sum operatios are performed, which gives the iitial coditios a 0 = a 1 = 0. For > 1, we have that the recursive procedure calculates the ( 1)th ad ( )th umber ad adds them together. Calculatig the ( 1)th umber requires a 1 sum operatios, ad calculatig the ( )th umber requires a of them. We the have oe more sum operatio to add the two umbers together, givig that: a = a 1 + a + 1. This is a ohomogeeous recurrece relatio. The associated homogeeous recurrece relatio is: = a (h) 1 + a (h) which has characteristic equatio: This equatio has roots: a (h) r r 1 = 0. r = b ± b 4ac a = 1 ±. Thus, the homogeeous relatio has solutio: ( a (h) 1 + ) ( 1 ) = α + β for values α, β that we will later derive from the iitial values. We ow eed to fid a particular solutio to the origial recurrece. Sice F () = 1, we have that the polyomial part is 1, so t = 0, ad the expoetial part is 1 = 1, so s = 1. Thus, the particular solutio has form: = (p)1 = p

for some value p. relatio: To fid p, we substitute the particular solutio ito the origial Thus, the geeral solutio is: a = a (h) + = α a = a 1 + a + 1 p = p + p + 1 p = 1 Usig the iitial values, we have that: ( 1 + ) ( 1 ) + β 1 a 0 = 0 = α + β 1 ( 1 + ) ( 1 ) a 1 = 0 = α + β 1 The solutio to this system of equatios is: α = + 10, β =. 10 Thus, the solutio to the recurrece relatio is: a = + ( 1 + ) + ( 1 ) 1. 10 10. Cosider the method by Karatsuba for multiplicatio of large itegers give below: procedure KMULT(A, B, : A ad B are itegers with bits) 1. If = 1 the retur A B;. else Write A = A h / + A l ad B = B h / + B l 3. Compute A = A h + A l ad B = B h + B l 4. C = KMULT(A, B, /). D h = KMULT(A h, B h, /) 6. D l = KMULT(A l, B l, /) 7. retur X = D h + [C D h D l ] / + D l (a) Based o the program we ca see that the umber of basic operatios for lie 1 is 1 ad the total umber of basic operatios for lies, 3 ad 7 is at most C for some costat C (sice the operatios are o umbers of at most bits). Write a recurrece relatio for T (), the umber of basic operatios used i all recursive calls for the cases i which is a power of (i.e. = k for some k). 6

(b) Use the master theorem (page 479) to fid a big-oh estimate for T (). We have that there are three recursive calls to KMULT with sequeces of about half the umber of the origial umber of bits, thus givig that the recurrece relatio is: ( ) T () = 3T + C. Additioally, T (1) = 1 sice whe = 1, we perform oe operatio (lie 1). This, however, is ot ecessary to apply the master theorem. Usig the master theorem, we have that a = 3, b =, ad d = 1. Thus, b d = 1 =, ad we have that a > b d. Hece, we are i the third case of the master theorem, which says that T () is O( log b a ) = O( log 3 ) = O( 1.8 ). 7