Reported interview periodDec 2025–Aug 2026
First-fit heap blocks
Implement a memory allocator over a fixed contiguous address range. Maintain free blocks in a doubly linked list ordered by starting address.
Practice focusallocate(size) must select the first block large enough for the request. Remove an exact-fit block; otherwise advance its start address and reduce its size. Return the allocated start address, or -1 when no block can satisfy the request. free(address, size) returns a region to the free list. Insert it in address order and coalesce it with an adjacent block on the left, right, or both sides when their boundaries touch. Preserve list ordering and links after every operation. Follow-ups 1. Reject overlapping or double frees without corrupting state. 2.…