Microsoft Interview Question for Software Engineer in Tests






Comment hidden because of low score. Click to expand.
0
of 0 vote

I think this is de-fragment and not fragment, right?

- ibnipun10 August 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Did they want code or just ideas?

- Anonymous August 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

did he mean using delimiters like NULL and fragmenting memory whenever you see a NULL?

- VVG August 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I am sorry yes its defragment. They need the algo as well as the code

- Meenu August 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hello,

Is this too much different than a sparse matrix optimization? If one assumes the occupied cells as 1 and unoccupied cells as 0, then it boils down to a representation of a sparse matrix in some form, may be an array or list.

- pradip.interra August 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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.

- Anonymous August 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Try thinking about java garbage collection strategy. You will get the answer.

- mpsajal August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

huffman coding gives pretty good compression and is easy to imlpmement as well

- Amit September 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I dont think its garbage collection coz we have defined empty and filled memory slots. Its more like how would you manage memory. There are two ways paging and segmentation. For implementation sake you can use array and write a code.

- janashilpa September 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In such type of questions is pseudo-code sufficient or just a class structure is required to mention?

Was this question asked during telephonic round or on sight??

- cirus September 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sp : on-site

- Anonymous September 28, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This looks like it can be solved using the Dutch National flag algorithm.

- Let bytes with NULL value be represented by 0
- Let invalid bytes be represented by -1
- Let valid bytes be represented by values other than 0 and -1

Define a method: void defrag(void *mem_loc) by shifting all zero's at the beginning, followed by -1's followed by the valid bytes. This can be easily done in O(n) time using Dutch national flag algo... in O(1) space...

- Rahul Arakeri September 22, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More