Answer to Question #235925 in Python for Reshma

Question #235925
Write a program on write an algorithm to find the total number of units of memory allocated or dellocated by the senser 1 after processing all the request
1
Expert's answer
2021-09-11T07:01:40-0400
class Memory:
    def __init__(self, size):
        self.memory = bitarray([0]*size, endian='little')
    def set_bool(self, addr, val):
    self.memory[addr] = val

def get_bool(self, addr):
    return self.memory[addr]

def set_i32(self, addr, val):
    bitarr = int2ba(val, length=INT_SIZE, endian='little')
    self.set_bitarray(addr, bitarr)

def get_i32(self, addr):
    bitarr = self.memory[addr:addr + INT_SIZE]
    val = ba2int(bitarr)
    return val

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS