Company: Ability_20oct
Difficulty: medium
Allocator Problem Description Implement a class Allocator that distributes variable allocations in the computer's memory. For this task, assume that the computer's memory consists of N bytes, addressed 0...N-1 . N is a power of 2. The class should provide the following functions: Allocator(int N) Creates an allocator, responsible for N bytes of memory. N is a power of 2. int alloc(int size) Allocates a variable of size bytes and returns the address of the first allocated byte. The size parameter is always 1, 4 or 8. The variable needs to be allocated size consecutive bytes. No byte can be allocated to two variables at once. If there is enough consecutive free space, the variable should always be allocated. If it is not possible to allocate the variable of the given size , the function should return -1 . void free(int address) Frees the variable allocated at the given address , which means that all bytes taken by the variable are no longer allocated. Assume that address is a value previ