page431.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 69 行
HTML
69 行
<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="tex2html6134" HREF="page432.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html6132" HREF="page415.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html6126" HREF="page430.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html6136" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION0013600000000000000000">Exercises</A></H1><P><OL><LI><A NAME="exercisegarbageexercise1"> </A> Let <I>M</I> be the size of the heap and let <I>f</I> be the fraction of the heap occupied by live data. Estimate the running time of the <tt>mark</tt> method of the <em>mark-and-sweep</em> garbage collection scheme as a function of <I>f</I> and <I>M</I>.<LI><A NAME="exercisegarbageexercise2"> </A> Repeat Exercise <A HREF="page431.html#exercisegarbageexercise1"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> for the <tt>copy</tt> method Estimate the running time of the <tt>copy</tt> method of the <em>stop-and-copy</em> garbage collection scheme.<LI><A NAME="exercisegarbageexercise3"> </A> Repeat Exercise <A HREF="page431.html#exercisegarbageexercise1"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> for the <tt>copy</tt> method Estimate the running time of the <tt>compact</tt> method of the <em>stop-and-compact</em> garbage collection scheme.<LI> Using your answers to Exercises <A HREF="page431.html#exercisegarbageexercise1"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>, <A HREF="page431.html#exercisegarbageexercise2"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> and <A HREF="page431.html#exercisegarbageexercise3"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>, show that running time of garbage collection is <em>inversely proportional</em> to the amount of storage recovered.<LI> The efficiency of a garbage collection scheme is the rate at which memory is reclaimed. Using your answers to Exercises <A HREF="page431.html#exercisegarbageexercise1"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> and <A HREF="page431.html#exercisegarbageexercise2"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> compare the efficiency of <em>mark-and-sweep</em> with that of <em>stop-and-copy</em>.<LI><A NAME="exercisegarbageexercise6"> </A> Devise a <em>non-recursive</em> algorithm for the <tt>mark</tt> method of the <em>mark-and-sweep</em> garbage collection scheme.<LI> Repeat Exercise <A HREF="page431.html#exercisegarbageexercise6"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> for the <tt>copy</tt> method of the <em>stop-and-copy</em> garbage collection scheme.<LI> Repeat Exercise <A HREF="page431.html#exercisegarbageexercise6"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> for the <tt>mark</tt> method of the <em>mark-and-compact</em> garbage collection scheme.<LI> Consider the use of <em>handles</em> for representing object references. Is it correct to assume that the order which objects appear in the heap is the same as the order in which the corresponding handles appear in the array of handles? How does this affect <em>compaction</em> of the heap?<LI> Consider the <tt>compact</tt> method of the <em>mark-and-compact</em> garbage collection scheme. The algorithm visits the objects in the heap in the order in which they appear in the heap, rather than in the order in which the corresponding handles appear in the array of handles. Why is this necessary?<LI> The <tt>compact</tt> method of the <em>mark-and-compact</em> garbage collection scheme slides the objects in the heap all to one end, but leaves the handles where they are. As a result, the handle array becomes <em>fragmented</em>. What modifications are necessary in order to compact the handle array as well as the heap?</OL><HR><A NAME="tex2html6134" HREF="page432.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html6132" HREF="page415.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html6126" HREF="page430.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html6136" 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 + -
显示快捷键?