Microsoft Interview Question for Software Engineer in Tests






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

Not possible unless size is known in advnace

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

Yes size is known.

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

template<class T>
class LinkedList
{
T node[100];
};

and add pointer operators overloaded function.

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

Forgot to add few more points..
- We need to add private new operator overloaded function.

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

Could any one explain what does template<class T> mean...
i'm a beginner...
also tell me in detail about the map class in C++,please

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

RTFM

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

He is asking you to 'read the fu*king manual'

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

class LinkedList<T> where T : struct
{
public LinkedList(int length)
{
end = -1;
coll = new T?[length];
}
int end;
T?[] coll;

public void add(T ele)
{
if (end + 1 < coll.Length)
{
end++;
coll[end] = ele;
}
}

public void remove(T ele)
{
for (int i = 0; i <= end; i++)
{
if (object.Equals(coll[i], ele)) coll[i] = null;
}
defragement();
}
public void print()
{
for (int i = 0; i <= end; i++)
Console.WriteLine(coll[i]);
}

private void defragement()
{
int np = -1;
for (int i = 0; i <= end; i++)
{
if (coll[i] == null && np == -1) np = i;
else if (coll[i] == null) continue;
else
{
if (np != -1)
{
coll[np] = coll[i];
coll[i] = null;
np++;
}
}
}
if (np != -1) end = np - 1;
}

}

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

Use the realloc() function to allocate more memory if needed..!!!!

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

using arrays in place of linked lists might lead to lots of copying of data in case of deletion. Just a thought...

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

for c coders
#define MAXSIZE 100 //assuming u know the sze already

struct list
{
int arr[100][2]; //Assuming implementing list for integers
int head;
};
typedef struct list List;

//now initialize head to 0 and start inserting data from arr[0][0] and arr[0][1] //will point to next node and so on..
//remember to fill free nodes wth some perticular value so tjat u know it is free

- Rookie_itbhu August 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Its not clear to me why do you have a 2D array in your struct definition ? Can you clarify ?

- A August 23, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Its not clear to me why do you have a 2D array in your struct definition ? Can you clarify ?

- A August 23, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

guys it's given properly in tenenbaum(data structures).
he has done it using arrays. and that too in a very efficient manner.

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

My Bit: In the data structure of the node itself store the index of next (and previous in doubly linkedlist) node. The basic difference is that in normal array based data structures the next element is in the next index(i+1) but in linkedlist it can be at different index.

struct node{
void * data;
int nextNodeIndex;
int prevNodeIndex;
}
typedef struct node LinkedListNode;

int headIndex;

//Create array of LinkedListNode of given n size.
//If n is not given, taken some default size (as in arraylist in java) and when full //double the size and copy the stored data in new array

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

head = -1, count = 0;

insert(int array, int node)
{
	array[count]=node;

	if(count == 0)
		head=array[count];
	
	count++;
}

int delete(int array, int node)
{
	if(count==0)
		retuen -1;

	int n=0, i=0;

	while(array[n]!=node)
		n++;

	for(i=count-n-1; i<count-1; i++)
		array[i] = array[i+1];

	count--;

	return 1;
}

- b November 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is right

- Anonymous March 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

head = -1, count = 0;

insert(int array, int node)
{
	array[count]=node;

	if(count == 0)
		head=array[count];
	
	count++;
}

int delete(int array, int node)
{
	if(count==0)
		retuen -1;

	int n=0, i=0;

	while(array[n]!=node)
		n++;

	for(i=count-n-1; i<count-1; i++)
		array[i] = array[i+1];

	count--;

	return 1;
}

- b November 20, 2010 | 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