Introduction to Algorithms, Second Edition

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

View Full Document Right Arrow Icon
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 )i f 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 n> 1): T ( n )= a · T
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2008 for the course CS 357 taught by Professor Ramachandran during the Spring '06 term at University of Texas.

Page1 / 3

Lecture 3 - The University of Texas at Austin Lecture 3...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online