X

# Microsoft  Questions

View By:

Q1 Linked List In C

Reorder A->B->C->D->E as B->A->D->C->E using linked list

Q2 N-2 Problem

You are given 2 machines. There are N jobs you have to perform. Job i takes Ai time to perform on machine A and Bi time to perform on machine B. Each job should be done either on machine A or B. The jobs should be performed in order. Given the arrays A and B and an integer K, find the minimum time required to complete the jobs, given that you cannot do more than K jobs on the same machine continuously. This can be done in O(N K)space and time. This can be improved to O(N K) time and O(N ) space and further to O(N logN ) time.

Q3 Convert a doubly linked list to a Binary Search Tree

Given a sorted doubly linked list, create a BST which is balanced and not skewed.

Q4 Test cases for overlap of rectangles

Given a function, func( rect a, rect b), which takes two rectangles as argument and tells if two rectangles overlap or not. Write all possible test cases for this.

Q5 Reverse a string - word by word

Reverse a string - word by word.

For example a string like "This is good day" would be written as

"day good is This"

# include

struct node { char info[50]; struct node link; }; struct node insert(struct node ,char ); struct node display(struct node start); int main() { char buff[50],str[50]; struct node *start=0; int i,j=0,cnt=0,k=0; printf("enter str:"); scanf("%[^\n]s",str);

for(i=0;str[i];i++) { j=i; while((str[i]!=' ') &&( str[i+1]!='\0')) { cnt++; i++; } for(k=0;k<=cnt;k++) { buff[k]=str[j++];

} buff[k]='\0'; start=insert(start,buff); cnt=0; } start=display(start);

printf(...
show more

Q6 Find out non repeating numbers

Given an array having numbers from 1 to N in random order such that all numbers except two are repeating twice, find out the two numbers.

Q7 Match two board configurations of tic-tac-toe problem

How will you match two board configurations of tic-tac-toe problem?

Q8 Copy sub-array within an array

Given an array, a start index, length and a dest index, copy the sub-array of given length from starting index to destination index.

Q9 How will you save binary tree in a disk such that you can retrieve it later

How will you save binary tree in a disk such that you can retrieve it later?

Q10 Find the sub-array with the largest sum

You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum. You are expected to give O(N) time solution. Write a routine in C for the above.