Implement the mark-scan collector (Exercises blah, blah, blah.) In exercise XXX, Use the following format for your GC statistics: \begin{verbatim} [GC stats: heap size 3960, live data 3528, ratio 1.12] \end{verbatim} Use exactly two digits after the decimal point to show the ratio. If there is no live data, your ratio should print as \texttt{infinite}. Use this format for memory statistics \begin{PRE} [Mem stats: allocated 244911, heap size 3960, ratio 61.85] \end{PRE} And this for total work. \begin{verbatim} [Total GC work: 745 collections traced 1988260 cells] \end{verbatim} Remember that the purpose of the garbage collector is to limit the amount of memory we have to request from the C~heap. If you call [[malloc]] anywhere but from within [[growHeap]], you are doing something wrong. (But you don't have to eliminate any existing calls to [[malloc]]; we've taken care of that in stage~1.) To implement the Stage~3 collector, I had to add or change 196~lines of code, of which 54~lines are devoted to debugging. You may want to plot work vs measured [[Gamma]] as well. [[{\htmlTilde}cs152/bin/jgraph]] is a good choice for plotting graphs, or you can use [[gnuplot]] or do it by hand. To help with your measurements, we are providing code that will spit out test cases using merge sort and insertion sort. If you call \texttt{{\htmlTilde}cs152/bin/mergetest 18} it will print out a definition of merge sort and a call to sort an 18-element array, so you can try \begin{PRE} {\htmlTilde}cs152/bin/mergetest 56 {\htmlBar} ./a.out \end{PRE} for example, to try out your own interpreter. (And you can see that it works with the regular Scheme interpreter.) A similar script called \texttt{inserttest} lets you try the exact same test but using an insertion sort. You will probably want to sort arrays of many different sizes as you gather your measurements. Note for the formula, ``as a function of gamma'' means gamma is the only parameter in your measuremnets. This means no other parameter, like heap size, amt of live data, fraction of cells allocated in last cycle, or anything else, should appear. For problems YYY and ZZZ, you can measure GC work in units of cells traced. Graphical comparison useful. For copying collection, When you enlarge the heap, be sure to do so in units of [[GROWTH_UNIT]]} (i.e., be sure the total heap size is always a multiple of [[GROWTH_UNIT]]), so as to facilitate comparisons with your mark-and-sweep collector. We reserve the right to use different values of [[GROWTH_UNIT]] to exercise your collector, so \textbf{you should be sure that your program works with any positive value of [[GROWTH_UNIT]]}. It is quite difficult to test a garbage collector, so the bulk of your grade will be based on your ability to convince us that you have implemented a correct collector. Don't forget to explain what you have done, and don't leave your explanation for the last minute! If you want to use \texttt{noweb} to help explain what you are doing, you might want to start with the noweb source for the stage 1 collector.