Interview Questions

Give an algorithm to compress a memory .....

Software QA/Tests Interview Questions from Microsoft

(Continued from previous question...)

Give an algorithm to compress a memory .....

Give an algorithm to compress a memory. To be more clear if you are given a memory of some stored data here and there and some empty and null memory in between, how will you fragment and compress your memory?

maybe an answer:

We can have an have linked list of struct containing memory add and its availability. So suppose first one is occupied then go to next struct in linked list. If that one it empty then the memory block is empty with this starting addr till the next structs memory address as the linked list is arranged ascending order of memory addr.
If two continues elements in linked list have the same status of availability then they can be merged.

(Continued on next question...)

Other Interview Questions