Answered step by step
Verified Expert Solution
Link Copied!

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

(15 marks) In some computer systems, R M 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 64 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 1 byte (fixed size).
You will implement this using one 1-D array, which combines two stacks. You
will need to implement the following operations:
isEmpty (for each R M 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 M area)
Do not use the built-in 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
(i.e. test for memory exhaustion).
(c) Give the time complexity for each of the operations, with justifications.
image text in transcribed

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

More Books

Students also viewed these Databases questions