
Microsoft Corporation


10+ Microsoft Corporation Software Engineer Interview Questions and Answers for Freshers
Q1. You have a cuboid (m*n*p) each block of the cuboid is having a metallic ball. Now we are passing X-ray from front face and getting a bool matrix1 of m*p the elements are set if there is a black spot.(as we are...
read moreYes, it is possible to get the accurate result from the given data.
The coordinates (i,j,k) where metallic balls are present can be determined by finding the set elements in both matrix1 and matrix2.
Additional data is not required as the given data is sufficient to determine the coordinates.
The coordinates can be obtained by iterating through the elements of matrix1 and matrix2 and checking for set elements.
Q2. Write a program to store a tree on a file. Also write code to reconstruct the tree from that file. Think of efficient techniques
Program to store and reconstruct a tree from a file with efficient techniques.
Use a recursive approach to traverse the tree and write each node to the file
Include information about the node's parent and children in the file
Use a unique identifier for each node to reconstruct the tree from the file
Use a data structure like a hash table to store the nodes and their identifiers for efficient reconstruction
Q3. Given a string of unknown length, what is a good approach to find n-k th element from last
To find n-k th element from last in a string of unknown length
Traverse the string to find its length
Calculate the position of n-k th element from last
Traverse the string again to find the element at calculated position
Q4. You have a Binary tree having numbers>=0 and a numeber N. Print all downwards paths from any node having the sum of elements equal to N
Print all downward paths from any node in a binary tree with sum of elements equal to N.
Traverse the binary tree and keep track of the sum of elements in the path from root to current node.
If the sum equals N, print the path from root to current node.
Recursively traverse the left and right subtrees with updated sum.
Use a stack to keep track of the current path being traversed.
Example: Binary tree with root 1, left child 2, right child 3, and N=3. Output: [1,2], [1,3].
Q5. Write the backend server code for a tic tac toe game
Backend server code for a tic tac toe game
Create a RESTful API using a framework like Express.js
Implement game logic to check for winning conditions
Use a database to store game state and user information
Handle user authentication and authorization
Implement real-time updates using WebSockets
Q6. Given an array of strings, count the number of unique occurrences
Count the number of unique occurrences in an array of strings.
Create a hash table to store the count of each string occurrence.
Iterate through the array and update the count in the hash table.
Count the number of unique occurrences by counting the number of keys in the hash table.
Q7. Variation of aggressive cows problem (requires binary search)
Use binary search to find the minimum distance to escape aggressive cows in a field.
Implement a function to check if cows can be placed with a minimum distance in a field.
Use binary search to find the minimum distance that satisfies the condition.
Keep track of the maximum distance found so far while performing binary search.
Q8. implement stack using linkedlist
Implementing stack using linked list
Create a Node class with data and next pointer
Create a Stack class with top pointer
Implement push() method to add element to top of stack
Implement pop() method to remove element from top of stack
Implement peek() method to return top element without removing it
Q9. variation of 2 sum problem
Find two numbers in an array that add up to a target sum.
Use a hash map to store the difference between the target sum and each element.
Iterate through the array and check if the current element's complement exists in the hash map.
Return the indices of the two numbers that add up to the target sum.
Q10. implement priority queue
Priority queue is a data structure that stores elements with priority levels and retrieves them in order of priority.
Elements are added with a priority level and retrieved in order of priority
Can be implemented using a heap data structure
Operations include insert, delete, and peek
Can be used in algorithms such as Dijkstra's shortest path algorithm
Q11. design a rest API
Design a REST API for a software engineer interview
Define the resources and endpoints
Use HTTP methods for CRUD operations (GET, POST, PUT, DELETE)
Implement authentication and authorization
Use JSON for data exchange format
Include error handling and status codes
Q12. DSA qn on graphs
Graphs are data structures that consist of nodes and edges connecting them.
Graphs can be directed or undirected.
Common graph traversal algorithms include BFS and DFS.
Examples of graphs include social networks, road networks, and computer networks.
More about working at Microsoft Corporation




Top HR Questions asked in Microsoft Corporation Software Engineer for Freshers
Interview Process at Microsoft Corporation Software Engineer for Freshers

Top Software Engineer Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

