Question: A question in data structuers and algorithms For example, in order for a garbage collector to be able to keep track of memory usage, you

A question in data structuers and algorithms

For example, in order for a garbage collector to be able to keep track of memory usage, you need to keep track of how many and which references there are for each allocated memory area. In the most common and simplest case, there is only one pointer / reference that refers to a certain area, but there is no upper limit for how many pointers / references can be allowed to reference there.

Implement a data structure in C that represents smart pointers. The features that must be included are:

* alloc: int --> ref (Assigns memory of a certain size and returns reference there)

* assign: ref --> ref (The outer reference refers to the same thing as the inner reference)

* free: ref --> ref (the reference points to NULL / nil afterwards)

* gc: 0 --> 0 (Free up memory that is no longer referred to)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!