Microsoft Interview Question
Software Engineer in Tests1 solution, you can have 2 linked lists: Free List , occupied list. Initially the free list contains one cell with data= total capacity of available. once a request comes(malloc), one entry is added occupied list with size=request_size, and offset of memory location. The poiter is returned using the offset value stored.
Once a Free is encountered, Free list is added with size, offset value.
Malloc will search through free list of size and will also modify the free list(size) if a block is found and allocated.
Above sequence happens
i got this question too...does any1 know the algorithm and code for this??
- Anonymous February 11, 2011