Just launched! Get 30% off The Imposter's Frontend Accelerator Get It Now

DFS, BFS and Binary Tree Search

7 years ago | Interview Prep Videos
You now know all about trees and graphs - but how do you use them? With search and traversal algorithms of course! This is the next part you'll need to know when you're asked a traversal question in an interview. And you will be.

When I interviewed at Google in 2015 I was asked a Depth-first search question. I couldn't believe it! I actually giggled about it - but not in a condescending way - I had just read an article that stated flatly "if you interview at Google, you better know your binary tree algorithms" and boom! There it was.

The question had to do with lines of succession in a royal family tree and it was a lot of fun to work through it. Believe it or not I enjoyed it and the interviewer seemed to be happy with my answer!

Another super popular interview is question is about balancing a binary tree. You usually find these questions in the screening phase - they're considered a little easier to deal with than the more complex questions we'll tackle later on.

To balance a binary tree you'll need to know how to efficiently traverse it - that's where depth-first and it's couterpart breadth-first search come in.

There's More...

The Imposter's Frontend Accelerator

JavaScript client frameworks are powerful and help you create an amazing experience for your end user. Unfortunately, learning how to use them sucks.

🤖 A Real World Approach to Playwright

Writing tests can be tricky, especially using a more complex tool like Playwright. I took some time and dug in over the last year and I'm happy I did.

What Is Your Yeet Threshold?

Solving problems is what we do, but sometimes the solution is to burn it all down and start again, learning from your mistakes. How do you make this choice?