Question
question 2 First-fit or Best-fit allocation Input You will process a text file to get the series of allocation, reallocation, and free calls that your
question 2
First-fit or Best-fit allocation
Input
You will process a text file to get the series of allocation, reallocation, and free calls that your simulator should make on your simulated heap. The input file will be in the form of a simple comma-separated value format in which each line describes a single call.
Example:
a, 5, 0 a, 25, 1 a, 1, 2 r, 10, 1, 3 f, 2
Calls to myalloc will be indicated in the input file as follows:
An "a" to indicate that this is an allocation call
An integer to indicate the "size" parameter
An integer between 0 and 999 to act as a reference the block allocated by the call
This value will be used to tie future calls to "myfree" and "myrealloc"
You may use this value any way you wish. It can be used to name pointers returned by your simulator, as the key to key-value pairs that keep track of your simulated "pointer"s, etc. It is simply there to ensure that we are calling "myrealloc" and "myfree" on the correct blocks
Calls to myrealloc will be indicated in the input file as follows:
An "r" to indicate that this is a reallocation call
An integer to indicate the "size" parameter
An integer between 0 and 999 to reference which block created by a previous call to myalloc we are resizing
An integer between 0 and 999 to reference the new block allocated by the call
Calls to myfree will be indicated in the input file as follows:
An "f" to indicate that this is a free call
An integer between 0 and 999 to specify the allocation call that this call is freeing
So, let's break down the example above:
a, 5, 0 // ptr0 = myalloc(5) a, 25, 1 // ptr1 = myalloc(25) a, 1, 2 // ptr2 = myalloc(2) r, 10, 1, 3 // ptr3 = myrealloc(ptr1, 10) f, 2 // myfree(ptr2)
The above example assumes that you use the reference number appended to the string "ptr" as your returned pointer names, but, again, this is not required. You may use the reference numbers however you wish, but this is one example of how you can use them to make sure that you are calling your functions on the correct blocks.
You do not need to validate the input for this project. You may assume that all input files are formatted correctly when you process them.
Output
Your output from each run will be another comma-separated value text file called "output.txt"
Simply indicate the value of each word in your simulated heap in hexadecimal format. Start with word 0 and work your way up to whatever the last word in your heap ends up being after the simulation run.
0, 0x00000000 1, 0xfe54cb43 2, 0x002365cd
etc.
The first value indicates the word in question, and the second indicates the contents of that word (represented in hexadecimal). That is why there are 8 hexadecimal digits for each entry in the example above. Each word will contain 4 bytes since this is a 32-bit system. Your output file will be checked to ensure that the heap contains the correct headers, footers, and pointers (in the case of explicit free lists) for the simulation that has just been run.
Encapsulation, Inheritance, and Polymorphism Abstraction Encapsulation 1. Class or Interface 1. Abstract Method 2. Access Modifiers 2. Abstract Class - Default 3. Interface OOP Concept - Public - Private - Protected Polymorphism Inheritance 1. Parent Child Concept 1. Compile Time or Static Polymorphism 2. Types of Inhertance 2. Runtime or Dynamic Polymorphism - Single - Multilevel 2 Hierarchical 'the three pillars of object-oriented programming are encapsulation, inheritance, and polymorphism. Please explain what they are.17) Polymorphism enables one common interface for many implementations, and for objects to act differently under different circumstances. C++ supports several kinds of static (compile-time) and dynamic (run-time) polymorphisms, supported by the language features described above. Compile- time polymorphism does not allow for certain run-time decisions, while run-time polymorphism typically incurs a performance penalty. a) What is meant by Polymorphism? b) Explain Different typesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started