Problem Set 1 Solutions

Similar documents
Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

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

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

Model of Computation and Runtime Analysis

CS / MCS 401 Homework 3 grader solutions

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:

Data Structures and Algorithm. Xiaoqing Zheng

Test One (Answer Key)

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

Recurrence Relations

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

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

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

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

Fundamental Algorithms

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

CS 332: Algorithms. Quicksort

and each factor on the right is clearly greater than 1. which is a contradiction, so n must be prime.

Data Structures Lecture 9

Continued Fractions and Pell s Equation

Signals and Systems. Problem Set: From Continuous-Time to Discrete-Time

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

PAPER : IIT-JAM 2010

Algorithms and Data Structures Lecture IV

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

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.

PROBLEM SET 5 SOLUTIONS 126 = , 37 = , 15 = , 7 = 7 1.

Solutions to Math 347 Practice Problems for the final

Math 140A Elementary Analysis Homework Questions 1

Bertrand s Postulate. Theorem (Bertrand s Postulate): For every positive integer n, there is a prime p satisfying n < p 2n.

MATH 324 Summer 2006 Elementary Number Theory Solutions to Assignment 2 Due: Thursday July 27, 2006

Chapter 4. Fourier Series

Different kinds of Mathematical Induction

Math F215: Induction April 7, 2013

Read carefully the instructions on the answer book and make sure that the particulars required are entered on each answer book.

4.3 Growth Rates of Solutions to Recurrences

Sums, products and sequences

MATH 304: MIDTERM EXAM SOLUTIONS

Model of Computation and Runtime Analysis

Math 4400/6400 Homework #7 solutions

Infinite Sequences and Series

PUTNAM TRAINING PROBABILITY

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions

End-of-Year Contest. ERHS Math Club. May 5, 2009

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

SOLVED EXAMPLES

Curve Sketching Handout #5 Topic Interpretation Rational Functions

Linear Programming and the Simplex Method

Analysis of Algorithms. Introduction. Contents

(b) What is the probability that a particle reaches the upper boundary n before the lower boundary m?

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

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

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

Chapter Vectors

Dynamic Programming. Sequence Of Decisions

Dynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions

Zeros of Polynomials

ITEC 360 Data Structures and Analysis of Algorithms Spring for n 1

CS 5150/6150: Assignment 1 Due: Sep 23, 2010

MATH301 Real Analysis (2008 Fall) Tutorial Note #7. k=1 f k (x) converges pointwise to S(x) on E if and

SEQUENCE AND SERIES NCERT

These Two Weeks. Mathematical Induction Chapter 4 Lecture 10 & Lecture 13. CPRE 310 Discrete Mathematics. Mathematical Induction Problems

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

A B = φ No conclusion. 2. (5) List the values of the sets below. Let A = {n 2 : n P n 5} = {1,4,9,16,25} and B = {n 4 : n P n 5} = {1,16,81,256,625}

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

Math 113 Exam 3 Practice

Chapter 2. Asymptotic Notation

MATHEMATICS. 61. The differential equation representing the family of curves where c is a positive parameter, is of

MA541 : Real Analysis. Tutorial and Practice Problems - 1 Hints and Solutions

Introduction to Computational Biology Homework 2 Solution

Please do NOT write in this box. Multiple Choice. Total

The Binomial Theorem

COMP285 Midterm Exam Department of Mathematics

Objective Mathematics

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

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

Complex Analysis Spring 2001 Homework I Solution

PRACTICE FINAL/STUDY GUIDE SOLUTIONS

Disjoint set (Union-Find)

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016

sin(n) + 2 cos(2n) n 3/2 3 sin(n) 2cos(2n) n 3/2 a n =

Basic Sets. Functions. MTH299 - Examples. Example 1. Let S = {1, {2, 3}, 4}. Indicate whether each statement is true or false. (a) S = 4. (e) 2 S.

10-701/ Machine Learning Mid-term Exam Solution

THE SOLUTION OF NONLINEAR EQUATIONS f( x ) = 0.

Math 475, Problem Set #12: Answers

Seunghee Ye Ma 8: Week 5 Oct 28

Math 299 Supplement: Real Analysis Nov 2013

University of Colorado Denver Dept. Math. & Stat. Sciences Applied Analysis Preliminary Exam 13 January 2012, 10:00 am 2:00 pm. Good luck!

M A T H F A L L CORRECTION. Algebra I 1 4 / 1 0 / U N I V E R S I T Y O F T O R O N T O

MATH 10550, EXAM 3 SOLUTIONS

Course 8 Properties of Regular Languages

CS276A Practice Problem Set 1 Solutions

Regn. No. North Delhi : 33-35, Mall Road, G.T.B. Nagar (Opp. Metro Gate No. 3), Delhi-09, Ph: ,

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

1 Approximating Integrals using Taylor Polynomials

Chapter 7 COMBINATIONS AND PERMUTATIONS. where we have the specific formula for the binomial coefficients:

CHAPTER 1 SEQUENCES AND INFINITE SERIES

A Note on the Symmetric Powers of the Standard Representation of S n

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

Transcription:

V R N N N R f ] R S Itroductio to Algorithms September 12, 2003 Massachusetts Istitute of echology 6046J/18410J rofessors Shafi Goldwasser ad Silvio Micali Hadout 7 roblem Set 1 Solutios roblem 1-1 Recurrece Relatios Solve the followig recurreces Give a boud for each problem If you are uable to fid a boud, provide as tight upper ( or ) ad lower ( or ) bouds as you ca fid Justify your aswers You may assume that (a)! #"%$'&() - By part 1 of the Master Method (b) *,+-!!/1032 /4032* - By part 3 of the Master Method (c) 6, 6 87: ; < Substitute = for he resultig relatio is =>?@ BA C;= Clearly, this is => ad thus 6 (d) *D EF G H ( 1 1 1 3 + 4 + ) ( 1 1 1 3 + 4 + ) 2 NN I G %J K M M M M M M M M M M M MM R R R R 16 2 R S S S S S S S x S x16 S x2 S S S S S S 16x 16x16 16x2 2x 2x16 2x2 he figure above shows the recursio tree that helps us i guessig a solutio We have that U #"%$XW BY \^] a3bdc e \^] a3bdc g ïhj ( H gk l hus we guess that lm * ad we prove it by substitutio Assume that =>UDop = for a appropriate costat o ad for all =rqs he we have that

v ( \ 2 Hadout 7: roblem Set 1 Solutios t v ou sou a sou 3w a3b ox, c {z o yh a3b o h c o a-b ~} for o {z Hece, * the other had by ispectio we have g ƒ % * Hece l % (e) D hk{ * ˆ 87:? j (f) *D /1032s lš * (g) /40323 :* - By ispectio ad substitutio G k*œ & Œ /4032* - By part 2 of the Master Method roblem 1-2 Asymptotic Notatio Rak the followig fuctios by order of growth; that is, fid a arragemet }' }pžpžpž }' of the H fuctios satisfyig,,,, E k H artitio your list ito equivalece classes such that x ad are i the same class if ad oly if x* *' (he fuctio /40-2 is discussed o pages -6 of CRS) G 4 # & z ]%]%]%] z /4032! #"%$8 #"%$ /4032* #"%$ š/4032,{b /1032dC œ he followig are ordered asymptotically from smallest to largest, are as follows (two fuctios, ad are o the same lie if x *X ): ]%]%]%] z

Hadout 7: roblem Set 1 Solutios 3 /4032 š/4032 /4032d ž G 1 # & /40-2 #"%$ #"%$3 #"%$ z roblem 1-3 Sieve of Eratosthees DB he Sieve of Eratosthees, iveted circa 200 BC, is a algorithm to fid all prime umbers betwee 2 ad a iput umber Ÿ he algorithm works as follows: we begi with a list of all itegers from 2 to Ÿ For each = Ÿ, we cross out (ie mark as composite) each multiple of = (> = for @ ) that is less tha or equal to Ÿ Whe this process termiates, oly the prime umbers betwee 2 ad Ÿ are umarked

4 Hadout 7: roblem Set 1 Solutios Below, we give pseudocode for this algorithm At the begiig of the algorithm, every etry i the array is iitialized to true, ie is true for all } ˆŸ At the ed of the algorithm, is true iff is prime ERASHENES-SIEVE Ÿ : 1 et for all from 2 to Ÿ!ª «2 for = to Ÿ : 3 4 while y p= kÿ : l # {= `±6²! 6 D 7 edwhile 8 edfor he table below shows the values of the array elemets ³ŽpŽpŽXŸ (lie 7) durig a executio of the algorithm ru o iput Ÿ µ{z at the ed of each while loop i #¹ º #» º ¼ ½pº #¾ º # º ¼ ÁÀBº # º #à º ¼ œä)åæº œä{ä'º œä¹ º œä» º 1 2 F F F F F 3 F F F F F F 4 F F F F F F F F F F F F 13 F F F F F F rove that the ERASHENES-SIEVE algorithm is correct; that is, prove that upo termiatio, is true iff is prime Hit: You ca use the followig pre-coditio ad post-coditio ad you ca prove the suggested loop ivariat for the for loop (lie 2) et Ç is true iff is prime Ç Ç re-coditio: ŸÈ, ost-coditio: }ŠÉ such that ~ oop Ivariat: } É such that DŸ D= represet the statemet: l 6 We will use the give loop-ivariat for the for loop (lie 2) ad the relevat pre- ad postcoditios to prove the correctess of the algorithm We will ow prove the give loop ivariat Namely, we will prove by iductio that whe = is assiged the value (lie 2), Ç holds for all } Whe = is assiged the value 2, Ê is true sice it was iitialized to be true hus, we have proved that before we execute the for loop the first time, the base case of the loop ivariat holds

Hadout 7: roblem Set 1 Solutios Now we will assume that whe = use this iductive hypothesis to prove that whe = })~, is assiged the value, Ç holds for all }g is assiged the value µ, Ç We will holds for all et s cosider a executio of the while loop with =r Sice goes from to ËŸ =Ì, y = is always at least Sice oly elemets with ˆy {= are (re)set to false, o elemet l 6 6 with will chage value hus, Ç for }, will hold at the ed of the executio of the while loop It remais to show that Ç holds at the ed of the executio of the while loop If Í is true, the it caot have ay divisor Î such that ÏÎ the it does ot have a divisor ÎÐ ivariat is correct So k must be prime If k is prime, hus, it must be true hus, we have proved that the loop Whe =mƒÿ, o the fial executio of the for loop, we have that Ç due to the correctess of the loop ivariat holds for all, ƒÿ,