page69.html

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

HTML
45
字号
<HTML><HEAD><TITLE>A Simple Example</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="tex2html2002" HREF="page70.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2000" HREF="page68.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1994" HREF="page68.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2004" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION003210000000000000000">A Simple Example</A></H2><P>Consider the function  <IMG WIDTH=165 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59389" SRC="img407.gif"  >which is shown in Figure&nbsp;<A HREF="page69.html#figomega"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.Clearly, <I>f</I>(<I>n</I>) is non-negative for all integers  <IMG WIDTH=39 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58503" SRC="img238.gif"  >.We wish to show that  <IMG WIDTH=91 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59395" SRC="img408.gif"  >.According to Definition&nbsp;<A HREF="page68.html#defnomega"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>,in order to show this we need to find an integer  <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline58491" SRC="img235.gif"  > and a constant <I>c</I><I>&gt;</I>0such that for all integers  <IMG WIDTH=47 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline58525" SRC="img239.gif"  >,  <IMG WIDTH=75 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59403" SRC="img409.gif"  >.<P>As with big oh, it does not matter what the particular constants are--as long as they exist!For example, suppose we choose <I>c</I>=1.Then<P> <IMG WIDTH=500 HEIGHT=66 ALIGN=BOTTOM ALT="eqnarray1734" SRC="img410.gif"  ><P>Since  <IMG WIDTH=85 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59407" SRC="img411.gif"  > for all values of  <IMG WIDTH=39 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58503" SRC="img238.gif"  >,we conclude that  <IMG WIDTH=46 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline59411" SRC="img412.gif"  >.<P>So, we have that for <I>c</I>=1 and  <IMG WIDTH=46 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline59411" SRC="img412.gif"  >,  <IMG WIDTH=75 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59403" SRC="img409.gif"  >for all integers  <IMG WIDTH=47 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline58525" SRC="img239.gif"  >.Hence,  <IMG WIDTH=91 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59395" SRC="img408.gif"  >.Figure&nbsp;<A HREF="page69.html#figomega"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> clearly showsthat the function  <IMG WIDTH=67 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline58565" SRC="img246.gif"  > is less thanthe function <I>f</I>(<I>n</I>)=5<I>n</I>-64<I>n</I>+256 for all values of  <IMG WIDTH=39 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58503" SRC="img238.gif"  >.Of course, there are many other values of <I>c</I> and  <IMG WIDTH=16 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline58491" SRC="img235.gif"  > that will do.For example, <I>c</I>=2 and  <IMG WIDTH=54 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline58553" SRC="img245.gif"  >.<P><P><A NAME="1791">&#160;</A><A NAME="figomega">&#160;</A> <IMG WIDTH=575 HEIGHT=322 ALIGN=BOTTOM ALT="figure1737" SRC="img414.gif"  ><BR><STRONG>Figure:</STRONG> Showing that  <IMG WIDTH=226 HEIGHT=28 ALIGN=MIDDLE ALT="tex2html_wrap_inline59467" SRC="img413.gif"  >.<BR><P><HR><A NAME="tex2html2002" HREF="page70.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2000" HREF="page68.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1994" HREF="page68.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2004" 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 + -
显示快捷键?