page347.html

来自「wqeqwvrw rkjqhwrjwq jkhrjqwhrwq jkhrwq」· HTML 代码 · 共 46 行

HTML
46
字号
<HTML>
<HEAD>
<TITLE>Running Time Analysis</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
 <img src="cover75.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/cover75.gif" alt="Logo" align=right>
<b>Data Structures and Algorithms 
with Object-Oriented Design Patterns in C++</b><br>
<A NAME="tex2html6213" HREF="page348.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page348.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/next_motif.gif"></A> <A NAME="tex2html6211" HREF="page345.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page345.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/up_motif.gif"></A> <A NAME="tex2html6207" HREF="page346.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page346.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/previous_motif.gif"></A> <A NAME="tex2html6215" HREF="page9.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page9.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/contents_motif.gif"></A> <A NAME="tex2html6216" HREF="page620.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page620.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/index_motif.gif"></A> <BR><HR>
<H3><A NAME="SECTION0011722000000000000000">Running Time Analysis</A></H3>
<P>
The running time of the downward pass of the insertion algorithm
is identical to that of an unsuccessful search
(assuming the item to be inserted is not already in the tree).
I.e., for a B-tree of height <I>h</I>,
the worst-case running time of the downward pass is 
<P> <IMG WIDTH=456 HEIGHT=17 ALIGN=BOTTOM ALT="displaymath65832" SRC="img1409.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1409.gif"  ><P>
<P>
The second pass of the insertion algorithm does the insertion
and balances the tree if necessary.
In the worst case,
all of the nodes in the insertion path up to the root need to be balanced.
Each time the <tt>InsertPair</tt> routine is invoked,
it calls <tt>FindIndex</tt> which has running time
 <IMG WIDTH=347 HEIGHT=26 ALIGN=MIDDLE ALT="tex2html_wrap_inline65840" SRC="img1410.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1410.gif"  > in the worst case.
The additional time required to balance a node is <I>O</I>(<I>M</I>).
Therefore, the worst-case running time of the upward pass is
<P> <IMG WIDTH=443 HEIGHT=17 ALIGN=BOTTOM ALT="displaymath65833" SRC="img1411.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1411.gif"  ><P>
<P>
Therefore, the total running time for insertion is
<P> <IMG WIDTH=447 HEIGHT=17 ALIGN=BOTTOM ALT="displaymath65834" SRC="img1412.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1412.gif"  ><P>
According to Theorem&nbsp;<A HREF="page340.html#theoremsrchtreeiii" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page340.html#theoremsrchtreeiii"><IMG  ALIGN=BOTTOM ALT="gif" SRC="cross_ref_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/cross_ref_motif.gif"></A>,
the height of a B-tree is  <IMG WIDTH=165 HEIGHT=25 ALIGN=MIDDLE ALT="tex2html_wrap_inline65844" SRC="img1413.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1413.gif"  >,
where <I>n</I> is the number of keys in the B-tree.
If we assume that two keys can be compared in constant time,
i.e.,  <IMG WIDTH=179 HEIGHT=26 ALIGN=MIDDLE ALT="tex2html_wrap_inline64824" SRC="img1296.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1296.gif"  >,
then the running time for insertion in a B-tree is simply  <IMG WIDTH=75 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline65850" SRC="img1414.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img1414.gif"  >.
<P>
<HR><A NAME="tex2html6213" HREF="page348.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page348.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/next_motif.gif"></A> <A NAME="tex2html6211" HREF="page345.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page345.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/up_motif.gif"></A> <A NAME="tex2html6207" HREF="page346.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page346.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/previous_motif.gif"></A> <A NAME="tex2html6215" HREF="page9.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page9.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/contents_motif.gif"></A> <A NAME="tex2html6216" HREF="page620.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page620.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/index_motif.gif"></A> <P><ADDRESS>
<img src="bruno.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/bruno.gif" alt="Bruno" align=right>
<a href="javascript:if(confirm('http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html'" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html">Copyright &#169; 1997</a> by <a href="javascript:if(confirm('http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html'" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.

</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?