📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Algorithms

Big O notation, time and space complexity, searching, sorting, recursion, dynamic programming basics, greedy algorithms and graph traversal (BFS and DFS).

  1. What is Big O notation? Explain O(1), O(log n), O(n), O(n log n), O(n²) and O(2ⁿ) with .NET examples, and the difference between best, average, worst-case and amortised cost.

    Big O notation as a growth-rate language: the common complexity classes, real .NET examples of each, and best/average/worst/amortised analysis.

    Junior Theory Algorithms Β· πŸ”— 3 follow-ups
  2. Code review: what is the time complexity of this .NET code, and how would you make it faster? It loops over orders, calls products.FirstOrDefault(p => p.Id == line.ProductId) per line, builds a report with string +=, and checks seen.Contains(order.Id) on a List<int>.

    Analysing the real time complexity of everyday .NET code with hidden loops, and rewriting it to linear time.

    Mid-Level CodeReview Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  3. What is space complexity? How do you analyse the memory an algorithm uses in .NET, including auxiliary space, recursion depth, allocations and the GC, and how do you trade time for space?

    Space complexity in practice: auxiliary versus input space, stack depth from recursion, allocation cost in .NET, and time-space trade-offs.

    Intermediate Theory Algorithms Β· πŸ”— 3 follow-ups
  4. How does binary search work? Implement it in C#, explain its preconditions and edge cases, and compare it with linear search and hash lookup. When would you use each in a .NET application?

    Searching algorithms: linear search, binary search (with a correct implementation and edge cases), hash lookup, and choosing between them in .NET.

    Intermediate Coding Algorithms Β· πŸ”— 3 follow-ups
  5. Which sorting algorithm does .NET use for Array.Sort and List<T>.Sort, and is it stable? Compare quicksort, merge sort, heap sort and insertion sort, and explain when OrderBy, a custom comparer or a non-comparison sort is the better choice.

    Sorting algorithms and their trade-offs, .NET's introsort, stability, OrderBy versus Array.Sort, comparers, and when to use counting or radix sort.

    Mid-Level Theory Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. What is recursion? Explain base cases, the call stack and stack overflow in .NET, then write a recursive and an iterative version of a tree or folder walk in C#. When should you avoid recursion?

    Recursion fundamentals: base and recursive cases, how the call stack works, StackOverflowException in .NET, and converting recursion to iteration with an explicit stack.

    Junior Coding Algorithms Β· πŸ”— 3 follow-ups
  7. What is dynamic programming? Explain overlapping subproblems and optimal substructure, compare memoisation (top-down) with tabulation (bottom-up), and solve a problem such as minimum coins for an amount in C#.

    Dynamic programming basics: recognising overlapping subproblems and optimal substructure, memoisation versus tabulation, and a worked minimum-coins example with space optimisation.

    Mid-Level Coding Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. What is a greedy algorithm? Give examples where greedy is optimal (interval scheduling, Dijkstra, Huffman) and where it fails (coin change with arbitrary coins, 0/1 knapsack). How do you decide whether greedy is safe in a real system?

    Greedy algorithms: the greedy-choice property, classic optimal cases, counterexamples, and using greedy heuristics in production scheduling and allocation.

    Mid-Level Theory Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. What is graph traversal? Explain breadth-first search (BFS) with a C# implementation, why it finds the shortest path in an unweighted graph, and where you would use it in a real system.

    Graph traversal fundamentals and BFS: queue-based implementation, visited sets, shortest paths in unweighted graphs, levels, and real uses like degrees of separation and dependency impact.

    Intermediate Coding Algorithms Β· πŸ”— 3 follow-ups
  10. Explain depth-first search (DFS). Implement it recursively and iteratively in C#, and show how DFS detects cycles in a directed graph and produces a topological order, for example for build or migration dependencies.

    Depth-first search: recursive and iterative implementations, pre/post order, three-colour cycle detection, topological sort, connected components and backtracking.

    Mid-Level Coding Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. A .NET API endpoint was fast in testing but gets slower every month as production data grows, and now times out for your biggest customers. How would you find and fix an algorithmic complexity problem, and stop it happening again?

    End-to-end handling of a production complexity problem: spotting non-linear growth in metrics, profiling, identifying hidden O(n²) or N+1 patterns, fixing them, and preventing regressions.

    Senior RealWorldScenario Algorithms Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me