the recursion-tree method



Similar documents
Master of Science in Computer Science College of Computer and Information Science. Course Syllabus

1 Review of Newton Polynomials

Math 115 Spring 2011 Written Homework 5 Solutions

CS/COE

CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

Tree-Based Consistency Approach for Cloud Databases

Optimal Binary Search Trees Meet Object Oriented Programming

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

LeMoyne-Owen College Division of Natural and Mathematical Sciences COMPUTER ALGORITHMS, COSI 335 Fall Syllabus

8 9 +

4/1/2017. PS. Sequences and Series FROM 9.2 AND 9.3 IN THE BOOK AS WELL AS FROM OTHER SOURCES. TODAY IS NATIONAL MANATEE APPRECIATION DAY

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

To discuss this topic fully, let us define some terms used in this and the following sets of supplemental notes.

2.1 The Present Value of an Annuity

Master Degree in Computer Science and Networking

Finite Automata and Formal Languages

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

Sudoku Puzzles Generating: from Easy to Evil

Computer Science Theory. From the course description:

Sample Induction Proofs

Section IV.1: Recursive Algorithms and Recursion Trees

Math 55: Discrete Mathematics

Lecture 3: Finding integer solutions to systems of linear equations

Chapter 6. Cuboids. and. vol(conv(p ))

CS 575 Parallel Processing

9.2 Summation Notation

Lecture 1: Course overview, circuits, and formulas

Mathematical finance and linear programming (optimization)

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Fast Sequential Summation Algorithms Using Augmented Data Structures

SECTION 10-2 Mathematical Induction

FACTORING LARGE NUMBERS, A GREAT WAY TO SPEND A BIRTHDAY

1 Introduction. Dr. T. Srinivas Department of Mathematics Kakatiya University Warangal , AP, INDIA

Data Structures. Algorithm Performance and Big O Analysis

Week 1: Introduction to Online Learning

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

Mathematics for Algorithm and System Analysis

10.2 Series and Convergence

From Last Time: Remove (Delete) Operation

Dynamic Programming Problem Set Partial Solution CMPSC 465

Lecture Notes on Polynomials

Integer factorization is in P

From Binomial Trees to the Black-Scholes Option Pricing Formulas

Dick Schwanke Finite Math 111 Harford Community College Fall 2015

A Uniform Asymptotic Estimate for Discounted Aggregate Claims with Subexponential Tails

ON THE COMPLEXITY OF THE GAME OF SET.

1.2. Successive Differences

LECTURE 4. Last time: Lecture outline

THE SECURITY AND PRIVACY ISSUES OF RFID SYSTEM

Offline 1-Minesweeper is NP-complete

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

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,

Geometric Series and Annuities

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

GRID SEARCHING Novel way of Searching 2D Array

Mathematical Induction. Lecture 10-11

The P versus NP Solution

MACM 101 Discrete Mathematics I

The Classes P and NP

Dick Schwanke Finite Math 111 Harford Community College Fall 2013

Exact Polynomial-time Algorithm for the Clique Problem and P = NP for Clique Problem

Lectures 5-6: Taylor Series

Ph.D. Thesis. Judit Nagy-György. Supervisor: Péter Hajnal Associate Professor

Sequential Data Structures

SEQUENCES ARITHMETIC SEQUENCES. Examples

Mathematics 31 Pre-calculus and Limits

Priority Based Hard Handoff Management Scheme for Minimizing Congestion Control in Single Traffic Wireless Mobile Networks

Lecture 7: NP-Complete Problems

CS 2302 Data Structures Spring 2015

11 Multivariate Polynomials

Data Structures and Algorithms

Analysis of Algorithms, I

Randomized algorithms

MCS5813 Cryptography Spring and select CRN 3850

UNIVERSITY OF LA VERNE COLLEGE OF LAW. NEGOTIATION EVENING CLASS (Law 550, Section 2)

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


Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series

SYLLABUS MAC 1105 COLLEGE ALGEBRA Spring 2011 Tuesday & Thursday 12:30 p.m. 1:45 p.m.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Pairwise Sorting Network

MAT225 Differential Equations Spring 2016

Notes from Week 1: Algorithms for sequential prediction

Investigating Area Under a Curve

1 Sets and Set Notation.

Course Objectives Course Requirements Methods of Grading S/N Type of Grading Score (%) Course Delivery Strategies Practical Schedule LECTURE CONTENT

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Grade 7/8 Math Circles Sequences and Series

Sequence of Numbers. Mun Chou, Fong QED Education Scientific Malaysia

Integration. Topic: Trapezoidal Rule. Major: General Engineering. Author: Autar Kaw, Charlie Barker.

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

Common Core Standards for Fantasy Sports Worksheets. Page 1

Transcription:

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 the form of the solution. 2 Use mathematical induction to find constants in the form and show that the solution works. In the previous lecture, the focus was on step 2. Today we introduce the recursion- method to generate a guess for the form of the solution to the recurrence.

the recursion- method recurrence into a 1 recurrence into a 2

recurrence into a an Consider the recurrence relation T (n) =3T (n/4)+cn 2 for some constant c. We assume that n is an exact power of 4. In the recursion- method we expand T (n) into a : T (n) cn 2 T ( n 4 ) T ( n 4 ) T ( n 4 )

recurrence into a we expand T ( n 4 ) Applying T (n) =3T (n/4)+cn 2 to T (n/4) leads to T (n/4) =3T (n/16)+c(n/4) 2, leaves: c( n 4 )2 cn 2 c( n 4 )2 c( n 4 )2 T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 ) T ( n 16 )

recurrence into a we expand T ( n 16 ) Applying T (n) =3T (n/4)+cn 2 to T (n/16) leads to T (n/16) =3T (n/64)+c(n/16) 2, leaves: cn 2 c( n 4 )2 c( n 4 )2 c( n 4 )2 c( n n c( n c( c( n c( n n c( c( n c( n n c(

the recursion- method recurrence into a 1 recurrence into a 2

recurrence into a the cost at We sum the cost at of the : cn 2 = cn 2 c( n 4 )2 + c( n 4 )2 + c( n 4 )2 = 3 16 cn2 c( n n + c( n + c( + c( n n + c( n + c( + c( n n + c( n + c( =( 3 cn 2

recurrence into a adding up the costs T (n) = cn 2 + 3 ( ) 3 2 16 cn2 + cn 2 + 16 ( = cn 2 1 + 3 ( ) 3 2 16 16) + + The disappear if n = 16, or the has depth at least 2 if n 16 = 4 2. For n = 4 k, k = log 4 (n), we have: log 4 (n) T (n) =cn 2 i=0 ( ) 3 i. 16

recurrence into a geometric series Consider a finite sum first: n S n = 1 + r + r 2 + + r n = r i. To find an explicit form of the solution we do i=0 rs n = r + r 2 + + r n + r n+1 S n = 1 + r + r 2 + + r n (r 1)S n = 1 + r n+1 So the explicit sum is S n = r n+1 1 r 1.

recurrence into a Applying to with r = 3 16 leads to geometric sum S n = n i=0 r i = r n+1 1 r 1 log 4 (n) T (n) =cn 2 i=0 ( ) 3 i 16 ( 3 ) log4 (n)+1 T (n) =cn 2 16 1 3 16 1.

recurrence into a polishing the result Instead of T (n) dn 2 for some constant d, wehave Recall ( 3 ) log4 (n)+1 T (n) =cn 2 16 1 3 16 1. log 4 (n) T (n) =cn 2 i=0 ( ) 3 i. 16 To remove the log 4 (n) factor, we consider T (n) cn 2 i=0 ( ) 3 i 16 = cn 2 1 3 16 1 dn2, for some constant d.

the recursion- method recurrence into a 1 recurrence into a 2

recurrence into a verifying the guess Let us see if T (n) dn 2 is good for T (n) =3T (n/4)+cn 2. Applying the : T (n) = 3T (n/4)+cn 2 ( n ) 2 3d + cn 2 ( 4 ) 3 = 16 d + c n 2 = 3 (d + 163 ) 16 c n 2 3 16 (2d) n2, if d 16 3 c dn 2

the recursion- method recurrence into a 1 recurrence into a 2

recurrence into a Consider T (n) =T (n/3)+t (2n/3)+cn. c n 3 log 3/2 (n) c n 9 2n c 9 cn = cn + = cn c 2n 9 c 2n 3 + + + = cn 4n c 9. + = O(n log 2 (n))

recurrence into a Summary + Assignments We covered 4.4 of Introduction to Algorithms, 3rd edition by Thomas H. Cormen, Clifford Stein, Ronald L. Rivest, and Charles E. Leiserson. Assignments: 1 Consider T (n) =3T (n/2)+n. Use a recursion to derive a guess for an asymptotic upper bound for T (n) and verify the guess with the. 2 Same question as before for T (n) =T (n/2)+n 2. 3 Same question as before for T (n) =2T (n 1)+1. Last homework collection on Monday 29 November: #1 of L-30, #1 of L-31, #3 of L-32, #2 of L-33, #1 of L-34. Final exam on Tuesday 7 December, 8-10AM in TH 216.