Microsoft Interview Question
Software Engineer in TestsI would use normal 2D matrix, with virtually allocated memory, commiting only the used cells. See VirtualAlloc() function in win32 for details. In this case this is very easy to use and memory consumption is just as needed. Using any of the suggested above methods will require keeping track of the unused and used cells - this code is going to be unmanageable...
Two dimensional Matrix will consume lot of memory...so we can use sparse matrix, where we can store non-null nodes. We can store the sparse matrix using linked lists inorder to utilize memory efficiently....
- Anonymous June 20, 2008