page77.html

来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 75 行

HTML
75
字号
<HTML><HEAD><TITLE>Reality Check</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html2094" HREF="page78.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2092" HREF="page72.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2086" HREF="page76.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2096" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION003450000000000000000">Reality Check</A></H2><P>``Asymptotic analysis is nice in theory,'' you say,``but of what practical value is it when I don't know what <I>c</I> and  <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline58491" SRC="img235.gif"  > are?''Fallacies&nbsp;<A HREF="page66.html#fallacyiii"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> and&nbsp;<A HREF="page66.html#fallacyiv"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> showed us that if we have two programs, <I>A</I> and <I>B</I>,that solve a given problem,whose running times are  <IMG WIDTH=81 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline60101" SRC="img512.gif"  > and  <IMG WIDTH=82 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline60103" SRC="img513.gif"  > say,we cannot conclude in general that we should use algorithm <I>A</I>rather than algorithm <I>B</I> to solve a particular instance of the problem.Even if the bounds are both known to be tight,we still don't have enough information.What we do know for sure is that <em>eventually</em>,for large enough <I>n</I>, program <I>A</I> is the better choice.<P>In practice we need not be so conservative.It is almost always the right choice to select program <I>A</I>.To see why this is the case,consider the times shown in Table&nbsp;<A HREF="page77.html#tblreality"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.This table shows the running times computed for a very conservative scenario.We assume that the constant of proportionality, <I>c</I>,is one cycle of a 1&nbsp;GHz clock.This table shows the running times we can expecteven if only one instruction is done for each element of the input.<P><P><A NAME="2516">&#160;</A><P>    <A NAME="tblreality">&#160;</A>    <DIV ALIGN=CENTER><P ALIGN=CENTER><TABLE COLS=5 BORDER FRAME=HSIDES RULES=GROUPS><COL ALIGN=CENTER><COL ALIGN=CENTER><COL ALIGN=CENTER><COL ALIGN=CENTER><COL ALIGN=CENTER><TBODY><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>	    </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> <I>n</I>=1 </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> <I>n</I>=8 </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=51 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60125" SRC="img515.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=75 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60127" SRC="img516.gif"  > </TD></TR></TBODY><TBODY><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> <IMG WIDTH=30 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60129" SRC="img517.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=55 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60139" SRC="img519.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=28 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60143" SRC="img520.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=36 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60145" SRC="img521.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=35 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60147" SRC="img522.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=32 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60149" SRC="img523.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=28 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60153" SRC="img524.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=43 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60155" SRC="img525.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=52 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60157" SRC="img526.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=67 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60159" SRC="img527.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=35 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60163" SRC="img528.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=49 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60165" SRC="img529.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=39 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60167" SRC="img530.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=39 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline60169" SRC="img531.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=36 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60173" SRC="img532.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=49 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60175" SRC="img533.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=87 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60177" SRC="img534.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=39 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline60179" SRC="img535.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=43 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60183" SRC="img536.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=39 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60185" SRC="img537.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=69 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60187" SRC="img538.gif"  > </TD></TR><TR><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP> 	     <IMG WIDTH=39 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60189" SRC="img539.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=27 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline60131" SRC="img518.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=43 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline60193" SRC="img540.gif"  > </TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=76 HEIGHT=30 ALIGN=MIDDLE ALT="tex2html_wrap_inline60195" SRC="img541.gif"  >		</TD><TD VALIGN=BASELINE ALIGN=CENTER NOWRAP>  <IMG WIDTH=75 HEIGHT=36 ALIGN=MIDDLE ALT="tex2html_wrap_inline60197" SRC="img542.gif"  > </TD></TR></TBODY><CAPTION ALIGN=BOTTOM><STRONG>Table:</STRONG> Actual lower bounds assuming a 1&nbsp;GHz clock,	 <IMG WIDTH=75 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline60117" SRC="img514.gif"  > and  <IMG WIDTH=46 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline59411" SRC="img412.gif"  >.</CAPTION></TABLE></P></DIV><P><HR><A NAME="tex2html2094" HREF="page78.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2092" HREF="page72.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2086" HREF="page76.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2096" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright &#169; 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

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