Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( 1 5 marks ) In some computer systems, R M is separated into sections. Usually one section is used for variables, another for function
marks In some computer systems, R is separated into sections. Usually
one section is used for variables, another for function call parameters, etc. In
this problem there will be two sections: variables and function call parameters.
Variables expand from one area of the RAM and function call parameters from the
other end see diagram
The amount of RAM is fixed. Think of RAM as one large static array, with one
end used for some purpose in this case variables and other end being used for a
different purpose in this case function call parameters The memory allocations
for these 'grow' towards each other. If the two ends ever meet, then the memory
has been exhausted. As you may have noticed, memory allocation and removal
behave like a Stack.
a In this question you will partially simulate this behaviour for the Microvision
handheld game console. The requirements for this simulation:
The R M size is bytes.
Allocations at the 'bottom' are for variables; 'top' are for parameters, just
like in the diagram.
When testing, you can add random characters to represent variables
parameters. You may assume each allocation is byte fixed size
You will implement this using one D array, which combines two stacks. You
will need to implement the following operations:
isEmpty for each R area
size for each R M area
allocate add an item to the proper RAM area, if space is available
free for each R M area
top for each R area
Do not use the builtin append or pop function, as these can change the size
of the aray
b Fully test all operations in a Python main program, including all corner cases
ie test for memory exhaustion
c Give the time complexity for each of the operations, with justifications.
Step 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