Lecture 3

# Introduction to Algorithms, Second Edition

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

The University of Texas at Austin Lecture 3 Department of Computer Sciences Professor Vijaya Ramachandran Divide & conquer; recurrence relations; master theorem CS357: ALGORITHMS, Spring 2006 Analyzing divide-and-conquer algorithms A divide-and-conquer algorithm has the following structure: Divide input problem (of size n ) into independent subproblems of the same type with smaller sizes (say n 1 , · · · , n a ). Conquer by solving the subproblems recursively . Combine solutions to subproblems to obtain solution to original problem. For example, in Merge-sort the divide step is trivial, the conquer step is performed by the two recursive calls to Merge-sort and the combine step is the call to Merge . Recurrence Relations. Let T ( n ) denote the running time of a divide-and-conquer algo- rithm as described above. If the divide step takes t D ( n ) time and the combine step takes t C ( n ) time, then, T ( n ) = t D ( n ) + X 1 i a T ( n i ) + t C ( n ) if n > 1 . T (1) refers to the base case, which takes constant time, so T (1) is a constant. (Sometimes the base case may occur at a large value than 1, but it occurs at some constant value for n , and the recurrence relation holds for values of n larger than that constant value.) Usually (but not always) the subproblems in the conquer step are all of the same size n/b , b > 1. In this case, we have a simpler recurrence relation (for

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