13recurenc_equat

13recurenc_equat - Introduction to Computers and...

This preview shows pages 1–8. Sign up to view the full content.

Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 13 Reading: Oct 2 2003

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Recap • Iteration versus Recursion • Towers of Hanoi • Computed time taken to solve towers of Hanoi
Divide and Conquer • It is an algorithmic design paradigm that contains the following steps Divide : Break the problem into smaller sub-problems Recur : Solve each of the sub-problems recursively Conquer : Combine the solutions of each of the sub-problems to form the solution of the problem Represent the solution using a recurrence equation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Recurrence Equation • A recurrence equation is of the form T(n) = aT(m) + b, n > 0, m < n (induction) and T(0) = constant (base case) Where: – aT(m): cost of solving a sub-problems of size m – b: cost of pulling together the solutions
Solving Recurrence Equations • Iteration • Recurrence Trees • Substitution • Master Method

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Towers of Hanoi T(n) = 2 T( n-1 ) +1 1 Given: T(1) = 1 N No.Moves 1 2 3 3 7 4 15 5 31
Using Iteration T(n) = 2 T( n-1 ) +1 T(n) = 2 [ 2 T(n-2) + 1 ] +1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern