Add office photos
Employer?
Claim Account for FREE

Microsoft Corporation

4.1
based on 1.6k Reviews
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

100+ Interview Questions and Answers

Updated 8 Aug 2024
Popular Designations
Q1. Buses

You are given a vector of 'N' integers denoting the number of buses that can be boarded from the i-th position. The bus stops only at stops whose number is a multiple of the bus stop number from which the ...read more

View 4 more answers
Q2. 9268 | Chess Tournament

Chess tournament is going to be organized in Ninjaland. There will be C chess players going to attend the tournament. All the players will be staying in a hotel. The hotel has N free room...read more

View 3 more answers
Q3. Day of the Week

Write a function that calculates the corresponding day of the week for any particular date in the past or future.

For example, for the date 28th August 2020 happens to be Friday. Hence the expect...read more

View 2 more answers
Q4. Fruits and Baskets

There are ‘n’ fruit trees that are planted along a road. The trees are numbered from 0 to n-1. The type of fruit each tree bears is represented by an uppercase character of the English alphabe...read more

View 3 more answers
Discover null interview dos and don'ts from real experiences
Q5. Check If One String Is A Rotation Of Another String

You are given two Strings 'P' and 'Q' of equal length. Your task is to check whether String 'P' can be converted into String 'Q' by cyclically rotating it to t...read more

View 2 more answers
Q6. Longest Mountain Subarray

You are given an array of 'N' integers denoting the heights of the mountains. You need to find the length of the longest subarray which has the shape of a mountain.

A mountain subarray ...read more

View 2 more answers
Are these interview questions helpful?
Q7. The Celebrity Problem

There are ‘N’ people at a party. Each person has been assigned a unique id between 0 to 'N' - 1(both inclusive). A celebrity is a person who is known to everyone but does not know anyone at...read more

View 4 more answers

Q8. You are given infinite sequence of continuos natural numbers-1,2,3,4,5,6.......... Initially you delete every 2nd element so sequence will be 1,3,,5,7,9,11,13..... now in the resultant sequence you delete every...

read more
Ans.

Program to check if a given number is a lucky number or not.

  • Create a function that takes an integer n as input

  • Initialize a variable count to 2

  • Loop through the sequence and delete every count-th element

  • Repeat the above step until the end of the sequence

  • If n is present in the final sequence, return true, else return false

View 1 answer
Share interview questions and help millions of jobseekers 🌟
Q9. Data Structure Supporting Insert Delete And GetRandom

Design and implement a data structure which supports the following operations:

insert(X): Inserts an element X in the data structure and returns true if the ...read more
View 2 more answers
Q10. Distinct Strings With Odd and Even Swapping Allowed

You are given an array of strings. Your task is to find the number of unique strings.

A string is considered unique if it cannot be formed from any other strin...read more

View 2 more answers
Q11. Kth largest element in the unsorted array

You are given an array consisting of 'N' distinct positive integers and a number 'K'. Your task is to find the kth largest element in the array.

Example:
Consider the ar...read more
View 2 more answers
Q12. Find all triplets with zero sum

You are given an array Arr consisting of n integers, you need to find all the distinct triplets present in the array which adds up to zero.

An array is said to have a triplet {arr...read more

View 2 more answers
Q13. Generate all binary strings from pattern

You're given a string 'STR' containing ‘0’, ‘1’ and ‘?’ special characters. Your task is to generate all the strings that are possible by replacing the special character ...read more

View 2 more answers
Q14. Sum of leaf nodes at maximum level

You have been given a binary tree of integers. Your task is to calculate the sum of all the leaf nodes which are present at the deepest level of this binary tree. If there are ...read more

View 4 more answers
Q15. First Missing Positive

You are given an array 'ARR' of integers of length N. Your task is to find the first missing positive integer in linear time and constant space. In other words, find the lowest positive in...read more

View 5 more answers
Q16. Maximum Subarray Sum

You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the subarray (including empty subarray) having maximum sum among all subarrays.

A subarray is a...read more

View 5 more answers
Q17. Total Strings

You are given a positive integer 'N'. Your task is to find the number of strings of length ‘N’ that can be formed using only the characters ‘a’, ‘b’ and ‘c’. The strings formed should be such that ...read more

View 3 more answers
Q18. Buy and Sell Stock

You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘N’ days. You can either buy or sell a stock. Also, you can only complete at most 2-transactions. Find...read more

View 4 more answers
Q19. Cycle Detection in a Linked List

You have given a Singly Linked List of integers, determine if it forms a cycle or not.

A cycle occurs when a node's next points back to a previous node in the list. The linked li...read more

View 4 more answers
Q20. Detect the first node of the loop

You have been given a singly linked list which may or may not contain a cycle. You are supposed to return the node where the cycle begins (if a cycle exists).

A cycle occurs whe...read more

View 4 more answers
Q21. Merge Sort

Given a sequence of numbers ‘ARR’. Your task is to return a sorted sequence of ‘ARR’ in non-descending order with help of the merge sort algorithm.

Example :

Merge Sort Algorithm - Merge sort is a Div...read more
View 3 more answers
Q22. Nearest Multiple of 10

You have been given an integer 'N'. Find the nearest multiple of 10 to the given integer 'N'.

Note:
If there are multiple answers, find the smallest one. For example, if N = 35, both 30 an...read more
View 2 more answers
Q23. Sum root to leaf

You are given an arbitrary binary tree consisting of N nodes where each node is associated with a certain integer value from 1 to 9. Consider each root to leaf path as a number.

For example:

 1 ...read more
Add your answer
Q24. Dice Throws

You are given D dice, each having F faces numbered 1 to F, both inclusive. The task is to find the possible number of ways to roll the dice together such that the sum of face-up numbers equal the giv...read more

View 5 more answers
Q25. N Queens

You are given an integer 'N'. For a given 'N' x 'N' chessboard, find a way to place 'N' queens such that no queen can attack any other queen on the chessboard.

A queen can be killed when it lies in the ...read more

View 2 more answers
Q26. IP Address

You are given a string “S” containing only digits from 0 to 9. Your task is to find all possible IP addresses that can be obtained from S in lexicographical order. If no valid IP address can be genera...read more

View 2 more answers
Q27. Look-And-Say Sequence

The Look-And-Say sequence is a sequence of positive integers. The sequence is as follows:

1, 11, 21, 1211, 111221, 312211, 13112221,...

This sequence is constructed in the following way:

Th...read more
View 2 more answers
Q28. Flatten Binary Tree

You are given a binary tree consisting of integer values. Your task is to convert the given binary tree into a linked list where the nodes of the linked list follow the same order as the pre-...read more

View 4 more answers
Q29. Check if given words are present in a string

Given a string 'S' and a list 'wordList' that consists of 'N' distinct words. Let 'Wi' denote word at index 'i' in 'wordList'. For each word 'Wi' in 'wordList', you n...read more

View 4 more answers
Q30. Add two numbers represented by linked lists

You have been given two singly Linked Lists, where each of them represents a positive number without any leading zeros.

Your task is to add these two numbers and print...read more

View 3 more answers
Q31. Word Break

You are given a list of “N” strings A. Your task is to check whether you can form a given target string using a combination of one or more strings of A.

Note :
You can use any string of A multiple tim...read more
View 5 more answers
Q32. Rearrange Array Numbers to form Largest Possible Number

You are given an array(ARR) of length 'N', consisting of non-negative integers. Using only these given numbers, rearrange the numbers in such a way that th...read more

View 2 more answers
Q33. Rooms

You are given some information about the rooms of a military camp. The rooms are numbered from 0 to 'N-1'. Each room contains keys to some other rooms. You can visit a room only if you have a key to that r...read more

View 4 more answers
Q34. Buying And Selling Stock

You have been given the prices of 'N' stocks in an array where each array element represents the stock price for that day. You need to find the maximum profit which you can make by buyin...read more

View 2 more answers
Q35. Maximum path sum between two leaves of a binary tree

You are given a non-empty binary tree where each node has a non-negative integer value. Return the maximum possible sum of path between any two leaves of the ...read more

View 3 more answers
Q36. Construct Binary Tree From Inorder and Preorder Traversal

You have been given the preorder and inorder traversal of a binary tree. Your task is to construct a binary tree using the given inorder and preorder tra...read more

View 2 more answers
Q37. Group Anagrams

You have been given an array/list of strings 'inputStr'. You are supposed to return the strings as groups of anagrams such that strings belonging to a particular group are anagrams of one another....read more

View 2 more answers
Q38. Delete N nodes after M nodes of a linked list

You have given a singly linked list and two integers 'N' and 'M'. Delete 'N' nodes after every 'M' node, or we can say more clearly that traverse the linked list suc...read more

View 2 more answers
Q39. Simplify the Directory

You are given a path to a file/directory in Unix-style of length N, In a Unix-style file system, a dot(.) refers to the current directory. A double dot(..) refers to the previous directory...read more

View 2 more answers
Q40. Gray Code

Given a number ‘grayNumber’. Find the gray code sequence.

Conditions for a gray code sequence :

1. Gray code sequence contains numbers from 0 to 2^'grayNumber'-1 in bit/binary form. 2. Two consecutive ...read more
View 4 more answers
Q41. Running median

You are given a stream of 'N' integers. For every 'i-th' integer added to the running list of integers, print the resulting median.

Input Format :
The fi...read more
View 4 more answers
Q42. Count Inversions

Let A[0 ... n-1] be an array of n distinct positive integers. If i < j and A[i] > A[j] then the pair (i, j) is called an inversion of A (where i and j are indexes of A). Given an integer array A...read more

View 4 more answers
Q43. Kth Smallest Element

You are given an array of integers 'ARR' of size 'N' and another integer 'K'. Your task is to find and return 'K'th smallest value present in the array.

Note: All the elements in the array a...read more

View 3 more answers
Q44. Time to Burn Tree

You have been given a binary tree of 'N' unique nodes and a Start node from where the tree will start to burn. Given that the Start node will always exist in the tree, your task is to print the...read more

View 3 more answers
Q45. Ninja And The Tree

Ninja is learning tree data structure these days. While learning, she came across learn about the Binary Search tree. She found BST quite interesting. She decided to make her own Binary Search...read more

View 2 more answers
Q46. Trapping Rain Water

You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that ...read more

View 3 more answers
Q47. Evaluate the Polynomial

You are given two arrays of coefficients and degrees of a polynomial expression. You need to simplify the polynomial in general form by evaluating and simplifying the expression.

For Exam...read more
View 2 more answers
Q48. Left view of binary tree

Given a binary tree. Print the Left View of the Tree.

Example :
If the input tree is as depicted in the picture: 

alt text

The Left View of the tree will be: 2 35 2 
Input format :
Elements in t...read more
View 2 more answers
Q49. Find the lone set bit

You are given a single non-negative integer ‘N’ who’s binary representation consists of a single ‘1’ digit and the rest of the digits are ‘0’s. Your task is to find the position of the only...read more

View 3 more answers
Q50. Minimize Cash Flow

You are given a list of ‘transactions’ between ‘n’ number of friends. who have to give each other money. The list consists of data of receiver, sender, and transaction.

Your task is to minimiz...read more

Add your answer
Q51. Spiral Order Traversal of a Binary Tree

You have been given a binary tree of 'N' nodes. Print the Spiral Order traversal of this binary tree.

For example
For the given binary tree [1, 2, 3, -1, -1, 4, 5, -1, -1,...read more
View 3 more answers
Q52. BST to sorted DLL

You are provided with a Binary Search Tree (BST), all you have to do is to convert it into the sorted doubly linked list (DLL).

For Example:

Example

Consider the above BST, it will be converted into t...read more

Add your answer
Q53. Count Squares

You are given a matrix of size N * M. Can you count the number of squares in it?

As the count will be very large, so compute it with modulo 10^9 + 7.

For Example:

Let N = 3 and M = 5 The number of ...read more
View 2 more answers

Q54. Which of the following numbers cannot be represented accurately in > binary? > a) 0.1 b) 6.5 c) 1/16 d)1.32 e) 0.590625 (not sure abt option e) > > 1. a only > 2. a and b > 3. a, b and d > 4. a, b and e > (not ...

read more
Ans.

Identifying which numbers cannot be accurately represented in binary.

  • Binary cannot accurately represent decimal fractions that do not have a power of 2 as their denominator.

  • Option a (0.1) and option e (0.590625) cannot be accurately represented in binary.

  • Option b (6.5) and option d (1.32) can be accurately represented in binary.

  • Option c (1/16) can be accurately represented in binary as 0.0001.

Add your answer
Q55. Spiral Matrix

You are given a N x M matrix of integers, return the spiral path of the matrix

Example Of Spiral Path

Spiral Path

Input Format:
The first line contains an integer 'T' which denotes the number of test cases or...read more
View 2 more answers
Q56. Minimum Fountains

There is a one-dimensional garden of length 'N'. On each of the positions from 0 to 'N', there is a fountain, and this fountain’s water can reach up to a certain range as explained further. In ...read more

View 2 more answers
Q57. System Design

You need to design a global auditorium booking platform, which could be booked from anywhere in the world. It can host multiple shows at once as it has 2 stages with different seating capacity. The...read more

Add your answer
Q58. Maximum meetings

You are given the schedule of N meetings with their start time Start[i] and end time End[i]. But you have only 1 meeting room. So, you need to tell the meeting numbers you can organize in the gi...read more

Add your answer
Q59. Minimum Number of Platform Needed

You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no ...read more

View 2 more answers
Q60. Design Tic-Tac-Toe

Ninja has to design a 2 players game Tic-Tac-Toe played on an ‘N’ * ‘N’ grid.

Ninja has to assume the following rules while playing the game:

This game is played between two people (Player 1 a...read more
View 2 more answers

Q61. You have 3 baskets- one containing apples, one oranges and the last containing both. All baskets are incorrectly labelled.You can pick *one* fruit from *any one* basket and are supposed to correctly label all o...

read more
Ans.

Pick a fruit from the basket containing both fruits and label the baskets accordingly.

  • Pick a fruit from the basket labelled 'apples and oranges'

  • If you pick an apple, label the basket containing only apples

  • If you pick an orange, label the basket containing only oranges

  • Label the remaining basket as containing both fruits

Add your answer

Q62. A process doesn't require additional processors to carry out 40% of > it's execution since 40% is mostly sequential. Determine how many > additional processors are required to execute the process in 150s if > t...

read more
Ans.

Additional processors required to execute a process in 150s with 40% sequential execution.

  • Process takes 300s on a single processor

  • 40% of the process is sequential and doesn't require additional processors

  • Calculate the time taken by the remaining 60% of the process

  • Determine the speedup required to execute the remaining 60% in 150s

  • Calculate the number of additional processors required based on the speedup

Add your answer
Q63. Water

You are given an array 'ARR' of positive integers, each of which represents the number of liters of water in that particular bucket, we have to make the liters of water in every bucket equal.

We are allowe...read more

Add your answer
Q64. Rat In A Maze

You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a squar...read more

Add your answer
Q65. Longest Duplicate Substring

You are given a string 'S' and you need to return the length of the longest duplicate substring in the given string. The occurrence of duplicate sub-strings can overlap also.

If there...read more

View 3 more answers

Q66. Given a string s[1...n] and a reverse function reverse(s, i, k) > which reverses the character sequence from i to k (inclusive of both) > in string s, determine what the following operations result in. > 1 > re...

read more
Ans.

Determining the result of string reversal and rotation operations using a reverse function.

  • The first operation reverses the first half and second operation reverses the second half of the string, resulting in a rotation of the string left k positions.

  • The third operation reverses the entire string, resulting in a reversal of the string.

  • Therefore, the correct answer is (b) Rotates the String left k positions.

  • Example: s = 'abcdefg', k = 3, reverse(s, 1, 3) = 'cbadefg', reverse(s...read more

Add your answer
Q67. Ninja and the Storyteller

Ninja is an avid story lover. Today, he decides to go to the famous Storyteller of Ninjaland to listen to new stories. The Storyteller takes 'Y' coins to tell one story. The Storytelle...read more

Add your answer
Q68. Remove K Digits

You are given a non-negative integer ‘NUM’ in the form of a string and provided with an integer ‘K’. You need to find out the smallest integer possible by removing exactly ‘K’ digits from ‘NUM.’

...read more
View 3 more answers
Q69. Basic OS Questions

What are the different operating systems? Batched operating systems
Distributed operating systems
Timesharing operating systems
Multi-programmed operating systems
Real-time operating systems

Add your answer

Q70. You're in the center of a circular pond, with an *intelligent* lion at the circumference - intelligent implies you can't trivially fool it. Given that, your swimming speed = x, lion's running speed on land = 4x...

read more
Ans.

Escape from an intelligent lion at the circumference of a circular pond with given speeds.

  • Swim towards the circumference of the pond to make the lion run a longer distance.

  • Once the lion is at a considerable distance, get out of the pond and run in the opposite direction.

  • Use obstacles like trees or rocks to slow down the lion.

  • Try to confuse the lion by changing directions frequently.

Add your answer

Q71. Given a bit pattern (in an integer INPUT), and another pattern (in an integer PATTERN, with a number n signifying the number of trailing bits to be considered as pattern - remaining bits are zero. Example: PATT...

read more
Ans.

Count the number of occurrences of a given bit pattern in an integer.

  • Extract the n trailing bits from the pattern and create a mask with all other bits set to zero.

  • Use a sliding window approach to compare the extracted pattern with all possible n-bit sequences in the input integer.

  • Increment a counter every time the extracted pattern matches with a sequence in the input integer.

View 2 more answers

Q72. Nice DP problem. Given an amount and an array containing possible coin denominations, determine the smallest no of coins in which the amount may be formed. Assume you have infinite units of each denomination

Ans.

Given an amount and coin denominations, find the smallest no of coins to form the amount.

  • Use dynamic programming to solve the problem

  • Create a table to store the minimum number of coins required for each amount

  • Iterate through the denominations and update the table accordingly

  • Return the minimum number of coins required for the given amount

Add your answer

Q73. If len is the length of the string and num is the number of > characters printed on the screen > Give the relation between num and len. > > void abc (char *s){ > if(s[0]=='�') > return; > > abc(s+1); > abc(s+1)...

read more
Ans.

Relation between num and len in a given code snippet

  • The code recursively calls the function abc() twice for each character in the string

  • The printf() statement prints each character once

  • The number of '>' characters printed on the screen is equal to num

  • The length of the string is equal to len

  • The relation between num and len is num = 2^len - 1

Add your answer
Q74. Min cost Path

Given an integer matrix of size m*n, you need to find out the value of minimum cost to reach from the cell (0, 0) to (m-1, n-1).

From a cell (i, j), you can move in three directions : (i+1, j), (i,...read more

Add your answer

Q75. What is deadlock?Conditions for that?What are the methods to prevent it?Write code to prevent the deadlock for OS, considering that there are two processes P0 and P1 in OS and they are requesting resources dyna...

read more
Ans.

Deadlock is a situation where two or more processes are unable to proceed due to a circular dependency on resources.

  • Deadlock occurs when two or more processes are waiting for resources held by each other.

  • Conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.

  • Methods to prevent deadlock include resource allocation graph, banker's algorithm, and deadlock avoidance.

  • To prevent deadlock in OS, use resource allocation graph and banker's algori...read more

Add your answer
Q76. Compress the String

Write a program to do basic string compression. For a character which is consecutively repeated more than once, replace consecutive duplicate occurrences with the count of repetitions.

For e.g...read more

View 2 more answers
Q77. OS Questions

What is a process?
What is a program?
Difference between a program and a process.
What is a thread?
What are the different states in a process life cycle?

Add your answer

Q78. Time complexity of a function f(m) is O(m). If the array[i...n] > contains either 1 or 0 in each of it's locations, determine the worst > case time complexity of the following piece of code written in C-like > ...

read more
Ans.

Determining worst case time complexity of a code snippet with given time complexity of a function and array

  • The time complexity of the given code snippet is O(n)

  • The function f(m) is called only when a 0 is encountered in the array

  • The worst case time complexity is O(n)

  • The code snippet iterates through the entire array once

Add your answer
Q79. Technical Questions

What is paging?

How virtual memory works ?

Why are you using SQL in your project and not NoSQL ?

How will it effect your app , and what changes need to make in order to convert SQL to No SQL DB?...read more

Add your answer
Q80. HR Questions

Three Questions were asked in this round: -

1. Why do you want Microsoft?

2. What are your career goals?

3. Why will you not accept the other offer you already have from a banking company?

Add your answer
Q81. OS Questions

What are semaphores?
What are the different types of semaphores?
What is a mutex?
What is a deadlock and how to handle it?

Add your answer
Q82. Operating System

1. When does deadlock occur?
2. What is the difference between process and threads?

Add your answer

Q83. “Compress a text string in place”. Having seen the famous string expansion in place problem many times, I promptly said run length encoding (i.e. compress aaaaaabbbbbccc to a6b5c3 for example). He asked me to c...

read more
Ans.

Code a run length encoding algorithm to compress a text string in place.

  • Use a loop to iterate through the string and count consecutive characters

  • Create a new string to store the compressed version of the original string

  • Add the character and its count to the new string

  • Compare the length of the new string to the original string to determine if compression was successful

Add your answer

Q84. Given an integer array, find all (a,b,c) such that a^2 + b^2 = c^2 Solution is O(n^2) Write code and testcases

Ans.

Given an integer array, find all (a,b,c) such that a^2 + b^2 = c^2. Solution is O(n^2). Write code and testcases.

  • Use nested loops to iterate through all possible pairs of integers in the array

  • Check if the sum of squares of the two integers is a perfect square

  • If yes, add the triplet to the result list

  • Return the result list

Add your answer

Q85. There is a roller which can have two types of wood blocks, 49 cm and 50 cm. Given two sensors 50 cm apart which call a function ring( ) whenever the sensor changes state, write the function ring( ) to calculate...

read more
Ans.

The function ring() calculates the number of blocks of both types based on sensor state changes.

  • Create a variable to keep track of the number of 49 cm blocks

  • Create another variable to keep track of the number of 50 cm blocks

  • Initialize both variables to 0

  • Whenever the sensor changes state, increment the corresponding block variable

  • Return the count of both block types as an array of strings

Add your answer

Q86. Data compression: Given a string “aabbbccc”, save it as “a2b3c3”. Here, I was asked to write a pseudocode, followed by a code in C++, optimize it and then all the testcases. Eg. “aabcc” would become “a2bc2” and...

read more
Ans.

Compress a string by replacing consecutive characters with their count.

  • Iterate through the string and count consecutive characters.

  • Append the character and its count to a new string.

  • Handle edge cases like single characters.

Add your answer
Q87. OOPS Questions

1.What is the difference between static polymorphism and runtime polymorphism?
2. What is a copy constructor? Tell any one use of it.
3. Define Encapsulation.

Add your answer
Q88. OOPS Questions

What is an abstract method?
What is polymorphism?
What is encapsulation?

Add your answer
Q89. Colour the Graph

You are given a graph with N vertices numbered from 1 to N and M edges. You have to colour this graph in two different colours, say Blue and Red such that no two vertices connected by an edge is...read more

View 2 more answers

Q90. Two numbers are stored in two linked lists, with one digit in each node. Add the numbers and return the resultant sum in a linked list. eg. if LL1= 2 ­> 3 ­> 5, LL2= 1­>4­>5, result should be LL3= 3­>8­>0...

read more
Ans.

The question asks to add two numbers represented as linked lists and return the sum as a linked list.

  • Traverse both linked lists simultaneously, adding the corresponding digits and carrying over the carry.

  • Create a new linked list to store the sum digits.

  • Handle cases where one linked list is longer than the other.

  • Consider cases where the sum has an additional carry digit at the end.

Add your answer
Q91. Product of Array except self

Given an array. Replace all the elements of the array with the product of all numbers except the number at that position. Do not use the division operator.

View 5 more answers

Q92. Increasing the RAM increases the efficiency of the CPU. The reason > is > a) Virtual memory increases > b) Number of page Page faults decreases > c) Page segmentation decreases > d) Increasing the amount of mem...

read more
Ans.

Increasing RAM improves CPU efficiency due to virtual memory and reduced page faults.

  • Increasing RAM allows for more data to be stored in memory, reducing the need for frequent access to slower storage devices.

  • Virtual memory allows the operating system to use hard disk space as if it were RAM, increasing the effective amount of memory available to the CPU.

  • Reducing page faults, which occur when the CPU needs to access data that is not currently in memory, improves CPU efficienc...read more

Add your answer
Q93. Sum Tree

Given a binary tree, convert it to its sum tree. That is, replace every node data with sum of its immediate children, keeping leaf nodes 0. And then return its preorder.

View 2 more answers

Q94. 1. Write a routine to output the elements of the inorder traversal of a binary tree one by one in its each call. eg: Assuming the inorder traversal is 1, 2, 3, 4, 5, the routine should return 1 in its first cal...

read more
Ans.

The routine should output the elements of the inorder traversal of a binary tree one by one in each call.

  • Implement an inorder traversal algorithm recursively

  • Use a global variable or pass a reference to keep track of the current element

  • Call the routine repeatedly to get the next element in each call

Add your answer

Q95. Given a compact data structure to store strings sequentially, one byte stores length l of the string, next l bytes contain the string characters. Write a code to insert the given string at the ith place, making...

read more
Ans.

The code inserts a given string at the specified position in a compact data structure that stores strings sequentially.

  • To insert the string at the ith place, we need to shift all the strings after the ith position by the length of the new string.

  • We can use a loop to iterate through the data structure and find the ith position.

  • After finding the ith position, we can calculate the new length of the data structure and allocate memory accordingly.

  • We then shift all the strings afte...read more

Add your answer

Q96. You hand over 'n' identical linked lists to n salespersons. After the day's work, these salesperson return the lists. Merge these lists such that all insertions, deletions, updates are taken care of, so that yo...

read more
Ans.

Merge 'n' identical linked lists from 'n' salespersons to handle insertions, deletions, and updates.

  • Iterate through each linked list and merge them into a single linked list

  • Handle insertions, deletions, and updates by traversing the merged list and making necessary changes

  • Repeat the process for the next day by resetting the merged list

Add your answer

Q97. What is the use of printf() and scanf() function?

Ans.

printf() is used to print formatted output to the screen, while scanf() is used to read formatted input from the user.

  • printf() is used to display output on the screen in a formatted way.

  • scanf() is used to read input from the user in a formatted way.

  • Example: printf("Hello, World!"); will display 'Hello, World!' on the screen.

  • Example: scanf("%d", &num); will read an integer input from the user and store it in 'num'.

View 2 more answers
Q98. Design a 2D Game

You want to design a game, 2D game. There are many objects in on the screen. You need to find whether these objects are overlapped or not. Size of the screen is given.
For simplicity, take the sh...read more

Add your answer
Q99. Basic SQL Questions

Write an SQL query to fetch records that are present in one table but not in another table

SELECT * FROM EmployeeSalary
MINUS
SELECT * FROM ManagerSalary;

Add your answer

Q100. 2 magnesium strips and a matchbox are given. Each burns in 60 minutes, with no relation between length burnt and time. Calculate 45 min

Ans.

Burning time of magnesium strips and matchbox given, calculate 45 min.

  • Calculate the total burning time of both magnesium strips and matchbox

  • Divide the total burning time by 4 to get the burning time of 1/4th of the material

  • Subtract the burning time of 1/4th of the material from the total burning time to get the remaining burning time

  • Divide the remaining burning time by 3 to get the burning time of 1/3rd of the remaining material

  • Add the burning time of 1/4th of the material an...read more

Add your answer
1
2

More about working at Microsoft Corporation

Top Rated Internet/Product Company - 2024
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 13 interviews in the last 1 year
2 Interview rounds
Coding Test Round
Technical Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.7
 • 115 Interview Questions
3.6
 • 64 Interview Questions
3.2
 • 39 Interview Questions
3.5
 • 24 Interview Questions
4.6
 • 11 Interview Questions
4.0
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter