Microsoft Interview Question for Software Engineer in Tests


Team: STB
Country: United States
Interview Type: In-Person




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

char BYTE[1000] = {};

char * getAllocation(unsigned int reqMemory)
{
	static unsigned int memCtr = 0;

	if(memCtr + reqMemory > 999)
		return NULL;

	memCtr += reqMemory;
	return &BYTE[memCtr-reqMemory];
}

- SauR January 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

refer K&R. It has given implementation, plus exercises would add real fire to the answer..

- Adorn December 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Did you mean Ansi C?

- Andy2000 December 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think best fit algorithm can be used for simulating memory management. Segments of free memory spaces can be kept track of through a BST and for every new memory allocation request, BST can be used to get the best fit available for that request.

- Srikanth January 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char BYTE[1000] = {};

char * getAllocation(unsigned int reqMemory)
{
static unsigned int memCtr = 0;

if(memCtr + reqMemory > 999)
return NULL;

memCtr += reqMemory;
return &BYTE[memCtr-reqMemory];
}

- Anonymous January 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
char byte[1000];

char* alloc(int siz)
{
static int ctr =0;
if(siz > 999-ctr) return NULL;
ctr=999-siz;
return ctr-siz;
}

}

- chetan kumar b v January 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Buddy system

- IntwPrep December 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

i wish the question was that simple but i think what the interviewer wants here is that you are given a fixed chunk of memory (say some byte array) from which you need to allocate memory chunks when malloc is called.

- The Artist December 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can't freelist be used here?

- alex December 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think main issue where is for that how to efficiently allocate memory where there are filed and unfilled spaces in byte array so that always we keep the bigger continuous allocation free.

- Andy2000 December 23, 2012 | Flag


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