pete > courses > CS 202 Spring 24 > Tier 2, Phase 2, Problem 05: Heap Structure
Tier 2, Phase 2, Problem 05: Heap Structure
The goals of this problem are to solidify your knowledge and understanding of The Heap. It is similar in style to the previous problem, t2p2p04: Stack Size, in that you will not be building a computational thing (like a circuit or a program) to specification; instead, you have questions to answer and will have to devise a program that helps you answer them.
These are the questions you must answer:
If you request two separate chunks of memory from The Heap in the same program, you’ll find they are not directly contiguous (i.e., right next to each other). How close are they?
How does the size of the chunks you request affect how close together they are?
If you request a chunk of memory from The Heap, you actually get more than you ask for. How much more? (Hint: consider how you can check whether you have access to a particular memory address; consider how the system tells you when you don’t.)
Why might The Heap behave like this? What benefit can you see to it setting aside way more memory than you asked for?
You will submit two files for this assignment:
- heap-structure.c will contain the C source code you write to answer these questions;
- README.txt will be a text file whose contents include answers to the questions above and a description detailing why the program you wrote answers the questions above. It should contain enough detail for me to reproduce your experiments and your results.
Submission Instructions
Copy the heap-structure.c and README.txt files to weathertop and then run:
$ 202 submit t2p2p05 heap-structure.c $ 202 submit t2p2p05 README.txt
Submissions will not be accepted after 2pm on Friday, 10 May.