subject
Computers and Technology, 09.04.2020 22:01 dymi6n

For question 1, I think the heap allocator allocates from higher addresses(at the end) to lower addresses(at the beginning).

and for question 2 and 3, I chose best fit for question 2 and none of the above for question 3, but not sure.

Need clear explanation for this kind of cases.



sizes between addresses = 1024, 64, 1024, 512, 1024, 128, 1024, 64, 1024
Question #1

If invoking the program as

memory 480,0,0,0
produced this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 |

The 480-byte chunk was allocated at address 2144
would you conclude that the heap allocator allocates new chunks of RAM at the beginning (i. e., lower addresses) or at the end (i. e., higher addresses) of holes in memory? Why? To explain why just use a contraposition argument (e. g., if the heap allocator did X then Y would have happened, but instead Z happened).

Whatever the heap allocator does, this is what we assume it does for all subsequent questions.

Question #2

If invoking the program as

./memory 100,200,100,80
produces this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 |

The 100-byte chunk was allocated at address 2524
The 200-byte chunk was allocated at address 2324
The 100-byte chunk was allocated at address 2224
The 80-byte chunk was allocated at address 3696
would you say that the heap allocator uses

first fit

best fit

worst fit

none of the above?

Question #3

If invoking the program as

./memory 40, 400, 80, 60
produces this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 |

The 40-byte chunk was allocated at address 3736
The 400-byte chunk was allocated at address 2224
The 80-byte chunk was allocated at address 2144
The 60-byte chunk was allocated at address 4804
would you say that the heap allocator uses

first fit

best fit

worst fit

none of the above?

Question #4

After looking up some documentation, you find out that the heap allocator uses worst fit! What would the output of the memory program be when invoked as follows:

./memory 400, 100, 10, 10

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, ksanchez2100
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
image
Computers and Technology, 23.06.2019 01:40, hanjonez
Writing a modular program in visual c++. i am new to this and not sure what i am missing. i am getting the following error: baddate. cpp: in function ‘int main()’: baddate. cpp: 50: 3: error: ‘else’ without a previous ‘if’elsehere are the instructions and code: writing a modular program in c++in this lab, you add the input and output statements to a partially completed c++ program. when completed, the user should be able to enter a year, a month, and a day. the program then determines if the date is valid. valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.notice that variables have been declared for you. write the simulated housekeeping() function that contains the prompts and input statements to retrieve a year, a month, and a day from the user. include the output statements in the simulated endofjob() function. the format of the output is as follows: month/day/year is a valid date. ormonth/day/year is an invalid date. execute the program entering the following date: month = 5, day = 32, year = 2014. record the output of this program. execute the program entering the following date: month = 9, day = 21, year = 2002. record the output of this /* program name: baddate. cppfunction: this program determines if a date entered by the user is valid. input: interactiveoutput: valid date is printed or user is alerted that an invalid date was entered*/#include bool validatedate(int, int, int); using namespace std; int main(){// declare variablesint year; int month; int day; const int min_year = 0, min_month = 1, max_month = 12, min_day = 1, max_day = 31; bool validdate = true; // this is the work of the housekeeping() method// get the year, then the month, then the daycout< < "enter the year"< > year; cout< < "enter the month"< > month; cout< < "enter the day"< > day; // this is the work of the detailloop() method// check to be sure date is validif(year < = min_year) // invalid yearvaliddate = false; else if (month < min_month || month > max_month) // invalid monthvaliddate = false; else if (day < min_day || day > max_day) // invalid dayvaliddate = false; // this is the work of the endofjob() method// test to see if date is valid and output date and whether it is valid or notif(validdate == true); {// output statementcout<
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, lizziesuks
What is the function of compilers and interpreters? how does a compiler differ from an interpreter?
Answers: 2
image
Computers and Technology, 24.06.2019 17:40, xinkyx616
Pseudocode pld #6, pg. 117 start// declarations// number numbertoguess// number myguess; numbertoguess = 92// while myguess ! = numbertoguess// output " guess an integer number between 1 and 100"// input myguess// if (myguess == numbertoguess)// output "you guessed the correct number"// else// output "the number you guessed was incorrect. try again! "// end if// end while// output " for playing the guessing game. have a great day! "// stop
Answers: 3
You know the right answer?
For question 1, I think the heap allocator allocates from higher addresses(at the end) to lower addr...

Questions in other subjects: