page58.html

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

HTML
61
字号
<HTML><HEAD><TITLE>Asymptotic Notation</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="tex2html1867" HREF="page59.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html1865" HREF="book.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1859" HREF="page57.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html1869" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION003000000000000000000">Asymptotic Notation</A></H1><P><A NAME="chapasymptotic">&#160;</A><P>Suppose we are considering two algorithms, <I>A</I> and <I>B</I>,for solving a given problem.Furthermore, let us say that we have done a careful analysisof the running times of each of the algorithms and determined them to be <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58477" SRC="img233.gif"  > and  <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58479" SRC="img234.gif"  >, respectively,where <I>n</I> is a measure of the problem size.Then it should be a fairly simple matter to compare thetwo functions  <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58477" SRC="img233.gif"  > and  <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58479" SRC="img234.gif"  > to determine whichalgorithm is <em>the best</em>!<P>But is it really that simple?What exactly does it mean for one function, say  <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58477" SRC="img233.gif"  >,to be <em>better than</em> another function,  <IMG WIDTH=41 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58479" SRC="img234.gif"  >?One possibility arises if we know the problem size <em>a priori</em>.For example, suppose the problem size is  <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline58491" SRC="img235.gif"  > and  <IMG WIDTH=118 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58493" SRC="img236.gif"  >.Then clearly algorithm <I>A</I> is better than algorithm <I>B</I>for problem size  <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline58491" SRC="img235.gif"  >.<P>In the general case, we have no <em>a priori</em> knowledge of the problem size.However, if it can be shown, say,that  <IMG WIDTH=104 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58501" SRC="img237.gif"  > for all  <IMG WIDTH=39 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58503" SRC="img238.gif"  >,then algorithm <I>A</I> is better than algorithm <I>B</I>regardless of the problem size.<P>Unfortunately, we usually don't know the problem size beforehand,nor is it true that one of the functions is less than or equal the otherover the entire range of problem sizes.In this case,we consider the <em>asymptotic</em> behavior<A NAME=1377>&#160;</A>of the two functions for very large problem sizes.<P><BR> <HR><UL> <LI> <A NAME="tex2html1870" HREF="page59.html#SECTION003100000000000000000">An Asymptotic Upper Bound-Big Oh</A><LI> <A NAME="tex2html1871" HREF="page68.html#SECTION003200000000000000000">An Asymptotic Lower Bound-Omega</A><LI> <A NAME="tex2html1872" HREF="page71.html#SECTION003300000000000000000">More Notation-Theta and Little Oh</A><LI> <A NAME="tex2html1873" HREF="page72.html#SECTION003400000000000000000">Asymptotic Analysis of Algorithms</A><LI> <A NAME="tex2html1874" HREF="page79.html#SECTION003500000000000000000">Exercises</A><LI> <A NAME="tex2html1875" HREF="page80.html#SECTION003600000000000000000">Projects</A></UL><HR><A NAME="tex2html1867" HREF="page59.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html1865" HREF="book.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1859" HREF="page57.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html1869" 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 + -
显示快捷键?