Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Garbage Collector Summary create a Python program (hw3.py) that simulates a Mark-Sweep garbage collection algorithm. In this program, named pointers are referred to using

Python Garbage Collector

Summary

create a Python program (hw3.py) that simulates a Mark-Sweep garbage collection algorithm. In this program, named pointers are referred to using variable names such asp,stackPtr,temp3, etc. Heap blocks are referred to using integers.

The program has the following functionality:

  1. Get the name of an input file from the command line (usingsys.argv). WARNING: Do not prompt the user for a file name.
  2. Process the file. The first line will containnnumber of heap blocks--the heap blocks will be identified using the numbers 0 throughn - 1. Each subsequent line will contain an ordered pair either in the form :
  • named pointer, heap block(example:p,10meansppoints to heap block 10)
  • heap block, heap block(example:7,3means heap block 7 points to heap block 3)
  1. Perform the mark-sweep algorithm.
  2. Output which heap blocks are marked and which heap blocks should be reclaimed (swept).
  3. The program must contain a function namedmark_sweepthat takes a filename string and returns a dictionary with two string keys 'marked' and 'swept' where the values for the 'marked' key is the ordered list of integers which are the marked nodes you'll print out and 'swept' is the ordered list of integers which are the swept nodes you'll print out. You can assu
    image text in transcribed
Example Diagram of heap: P O 7 3 N s -7 6 8 K

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions