page56.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 86 行
HTML
86 行
<HTML><HEAD><TITLE>Exercises</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="tex2html1847" HREF="page57.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html1845" HREF="page36.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1839" HREF="page55.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html1849" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION002300000000000000000">Exercises</A></H1><P><OL><LI><A NAME="exercisemodeli"> </A> Determine the running times predicted by the detailed model of the computer given in Section <A HREF="page37.html#secmodeldetailed"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> for each of the following program fragments: <OL><LI><PRE>i = 0while i < n: k += 1 i += 1</PRE><LI><PRE>i = 1while i < n: k += 1 i = i * 2</PRE><LI><PRE>i = n - 1while i != 0: k += 1 i = i / 2</PRE><LI><PRE>i = 0while i < n: if i % 2 == 0: k += 1 i += 1</PRE><LI><PRE>i = 0while i < n: j = 0 while j < n: k += 1 j += 1 i += 1</PRE><LI><PRE>i = 0while i < n: j = i while j < n: k += 1 j += 1 i += 1</PRE><LI><PRE>i = 0while i < n: j = 0 while j < i * i: k += 1 j += 1 i += 1</PRE> </OL><LI> Repeat Exercise <A HREF="page56.html#exercisemodeli"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>, this time using the simplified model of the computer given in Section <A HREF="page49.html#secmodelsimplified"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<LI> Prove by induction the following summation formulas: <OL><LI> <IMG WIDTH=112 HEIGHT=50 ALIGN=MIDDLE ALT="tex2html_wrap_inline58387" SRC="img208.gif" ><LI> <IMG WIDTH=178 HEIGHT=50 ALIGN=MIDDLE ALT="tex2html_wrap_inline58389" SRC="img209.gif" ><LI> <IMG WIDTH=133 HEIGHT=50 ALIGN=MIDDLE ALT="tex2html_wrap_inline58391" SRC="img210.gif" ></OL><LI> Evaluate each of the following series summations: <OL><LI> <IMG WIDTH=37 HEIGHT=50 ALIGN=MIDDLE ALT="tex2html_wrap_inline58393" SRC="img211.gif" ><LI> <IMG WIDTH=64 HEIGHT=53 ALIGN=MIDDLE ALT="tex2html_wrap_inline58395" SRC="img212.gif" ><LI> <IMG WIDTH=64 HEIGHT=53 ALIGN=MIDDLE ALT="tex2html_wrap_inline58397" SRC="img213.gif" ><LI> <IMG WIDTH=52 HEIGHT=49 ALIGN=MIDDLE ALT="tex2html_wrap_inline58399" SRC="img214.gif" ></OL><LI> Show that <IMG WIDTH=100 HEIGHT=27 ALIGN=MIDDLE ALT="tex2html_wrap_inline58401" SRC="img215.gif" >, for <IMG WIDTH=66 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58403" SRC="img216.gif" >. <b>Hint</b>: Let <IMG WIDTH=92 HEIGHT=27 ALIGN=MIDDLE ALT="tex2html_wrap_inline58405" SRC="img217.gif" > and show that <IMG WIDTH=161 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline58407" SRC="img218.gif" >.<LI> Show that <IMG WIDTH=95 HEIGHT=27 ALIGN=MIDDLE ALT="tex2html_wrap_inline58409" SRC="img219.gif" >. <b>Hint</b>: Let <IMG WIDTH=105 HEIGHT=27 ALIGN=MIDDLE ALT="tex2html_wrap_inline58411" SRC="img220.gif" > and show that the difference <IMG WIDTH=63 HEIGHT=23 ALIGN=MIDDLE ALT="tex2html_wrap_inline58413" SRC="img221.gif" > is (approximately) a geometric series summation.<LI> Solve each of the following recurrences by repeated substitution: <OL><LI> <IMG WIDTH=214 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58415" SRC="img222.gif" ><LI> <IMG WIDTH=261 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58417" SRC="img223.gif" ><LI> <IMG WIDTH=222 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58419" SRC="img224.gif" ><LI> <IMG WIDTH=225 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58421" SRC="img225.gif" ><LI> <IMG WIDTH=203 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58423" SRC="img226.gif" ><LI> <IMG WIDTH=211 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58425" SRC="img227.gif" ><LI> <IMG WIDTH=213 HEIGHT=56 ALIGN=MIDDLE ALT="tex2html_wrap_inline58427" SRC="img228.gif" ></OL></OL><HR><A NAME="tex2html1847" HREF="page57.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html1845" HREF="page36.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html1839" HREF="page55.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html1849" 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 © 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 + -
显示快捷键?