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

Running Time Analysis

The running time of merge sort is determined by the running time of the recursive sort method. (The no-arg sort method adds only a constant amount of overhead). The running time of the recursive sort method is given by the following recurrence:

  equation44080

where tex2html_wrap_inline69181.

In order to simplify the solution of Equation gif we shall assume that tex2html_wrap_inline57738 for some integer tex2html_wrap_inline60398. Dropping the tex2html_wrap_inline57116s from the equation we get

displaymath69183

which is easily solved by repeated substitution:

eqnarray44090

Therefore, the running time of merge sort is tex2html_wrap_inline58846.


next up previous contents index

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