Microsoft Software Developer Mock Interview

Practice 30 Microsoft Software Developer interview questions covering algorithms, system design, and coding assessments.

Question 7 of 30

Can you walk me through the meaning behind a Depth First Search Algorithm for a binary tree?

  • How to Answer

  • Example Answer

  • Community Answers

William Swansen
William Swansen

William Swansen has worked in the employment assistance realm since 2007. He is an author, job search strategist, and career advisor who helps individuals worldwide and in various professions to find their ideal careers.

When looking at a question of this magnitude, there are a number of different factors to consider. You will want to get clarification from the Microsoft interviewer on whether they want to hear the meaning for tree structure data, time complexity, extra space, or a node stack. Let's examine what some of these mean and how they might come up in the course of an interview. Time Complexity - has four transversals O(n) as they visit every node exactly once. Extra Space - requires O(w) Level Order Transversal where w is the maximum width of a Binary Tree which stores nodes of different levels. Interview-related questions might ask about typical binary tree numbers. 1, 3, 7, 15, or in a worst-case scenario, a value of 2h is Ceil(n/2) will usually come up as good answers to this question. A couple more that might come are when is extra space required for Level Order Transversal and Depth First Transversal. Two good responses can be a more balanced position for Level Order Transversal and a less balanced position for Depth First Transversal.

Unlock All 30 Microsoft Questions

Unlock expert responses shaped by Microsoft's rigorous technical interview process.

Get Started