Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Summary

For many divide-and-conquer algorithms the running time is given by the general recurrence shown in Equation gif. Solutions to the recurrence depend on the relative values of the constants a, b, and k. Specifically, the solutions satisfy the following bounds:

  equation32659

Table gif shows how to apply Equation gif to find the running times of the divide-and-conquer algorithms described in the preceding sections. Comparing the solutions in Table gif with those given in Table gif shows the results obtained using the general formula agree with the analyses done in the preceding sections.

 

 

program recurrence a b k case solution
Program gif T(n)=T(n/2)+O(1) 1 2 0 tex2html_wrap_inline67557 tex2html_wrap_inline67587
Program gif T(n)=2T(n/2)+O(1) 2 2 0 tex2html_wrap_inline67543 tex2html_wrap_inline67593
Program gif T(n)=2T(n/2)+O(n) 2 2 1 tex2html_wrap_inline67557 tex2html_wrap_inline67599
Table: Computing running times using Equation gif.


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.