# Microsoft Interview Questions with Answers

6 previously-asked interview questions from Microsoft's hiring process, each with the correct answer and a worked explanation. Written against the company's actual test pattern.

_Source: Astra (https://useastra.in). Updated 2026-09-05._

### 1. How would you design a data structure for a least recently used (LRU) cache?

**Answer:** Combine a hash map (key to node) with a doubly linked list ordered by recency. get and put move the node to the front; on overflow evict the tail. Both operations are O(1).

**Explanation:** Hash map plus doubly linked list.

### 2. What is the difference between an array and a linked list?

**Answer:** An array has contiguous memory and O(1) index access but a fixed size and costly insertions. A linked list uses nodes with pointers for dynamic size and O(1) insertion or deletion at a known position, at the cost of O(n) access and extra pointer memory.

**Explanation:** Contiguous fixed array vs dynamic pointer-based list.

### 3. What is recursion and what are its downsides?

**Answer:** Recursion is a function calling itself on smaller inputs with a base case. It is elegant for divide and conquer and tree problems, but uses call stack memory (risking stack overflow) and can recompute subproblems unless memoised.

**Explanation:** Self-calling with a base case; costs stack memory.

### 4. What is the difference between stack and heap memory?

**Answer:** Stack memory holds call frames and local variables, managed automatically in LIFO order, fast but limited. Heap memory is for dynamic allocation, managed manually or by a garbage collector, larger but slower and prone to fragmentation.

**Explanation:** Stack: automatic, fast, limited. Heap: dynamic, larger, slower.

### 5. What is a binary search tree and what are its operation complexities?

**Answer:** A BST keeps left descendants smaller and right descendants larger than each node. Search, insert, and delete are O(log n) when balanced but degrade to O(n) if the tree becomes skewed; self-balancing variants like AVL or red-black keep it O(log n).

**Explanation:** Ordered tree; O(log n) balanced, O(n) skewed.

### 6. Tell me about a challenging project you worked on and your role in it.

**Answer:** Use the STAR format: the Situation and Task, the technical challenges, the Actions you personally took (design, debugging, collaboration), and the measurable Result. Emphasise your contribution and what you learned.

**Explanation:** STAR: your contribution, decisions, and outcome.

More Microsoft preparation, including the full recruitment process: https://useastra.in/campus/microsoft
