DEV Community

Cover image for Cracking the Binary Tree Interview
Abdisalan
Abdisalan

Posted on • Updated on

Cracking the Binary Tree Interview

Hi everyone!

I recently finished 3 months of interviewing, and I received multiple offers! It was no walk in the park because my data-structures knowledge wasn't the best.

In particular, I was terrible at solving binary tree questions. So I practiced and practiced and practiced until I became confident I could solve almost any binary tree questions on LeetCode/HackerRank.

I want to prepare a guide that explains my process for solving these questions to help anyone struggling in this area or just want to refine their skills.

My question is, what would you expect from a complete guide on solving Binary Tree questions? My working outline so far is as follows:


Foundation
-Tree DS: class, insertion, deletion, array-based trees
-All Tree Traversals (recursive)
-All Tree Traversals (iterative)
-Tree specific Algorithms

How to Solve
-How to determine the type of question and solution (my guide)
-Common gotchas
-20+ Question Solution Explanations


Do you feel like something is missing? Please comment on any ideas you have or if you want to receive this guide when it releases!

I'll be working on this over the coming weeks and releasing it in pieces over twitter and devto. If you want to follow my process and get a behind the scenes look, follow me on Twitter!

Photo by Zane Lee on Unsplash

Top comments (13)

Collapse
 
pomfrit123 profile image
***

If programming is all about tree traversials then I dont really want to live in that world.

Collapse
 
abdisalan_js profile image
Abdisalan

Sorry, its a bit misleading but that wasn't the only type of question I was asked! Its just an area where a lot of people struggle in interviews.

It sucks that a lot of companies want to ask white board questions instead of testing your actual project making abilities but at the end of the day we still need a job :/

Collapse
 
pomfrit123 profile image
***

Yeah I know, interviews suck.

Collapse
 
moopet profile image
Ben Sinclair

I agree. I think that if companies are relying on cookie-cutter questions about things you'll never have to write in your entire time as an employee, then they;re going about interviews wrong.
That doesn't mean they'd be a bad company to work for, though.
While I can dredge up the memory of certain sorting algorithms when I really need to I usually try to get the interview into more of a conversation where I can explain what approach I'd use in the real world instead.

Collapse
 
not4ro profile image
Matteo Notaro

Well, i can also say that if "programming" it's all about doing "tumblr" stuff with js I don't really want to live in that world.
"Tree traversials" it's Computer Science, not programming. JS animations can be wrote by toddlers.

Collapse
 
abdisalan_js profile image
Abdisalan

We can make the distinction without attacking people who write js animations :)

Please be more considerate Matteo, it really goes a long way.

Thread Thread
 
not4ro profile image
Matteo Notaro

I mean, a lot of ppl thinks that CS is just doing fancy stuff with React/Angular & Co. and then say that real CS stuff are "cookie cutter" questions...

Collapse
 
pomfrit123 profile image
***

I dont know why people bother with animations, they don't improve anything.

Thread Thread
 
abdisalan_js profile image
Abdisalan

They improve the user experience! Imagine if there was no animation on any website, would that not be very bland?

Thread Thread
 
pomfrit123 profile image
***

They do, but sometimes they can be distracting :)

Collapse
 
abdisalan_js profile image
Abdisalan

A little update for those who aren't following on twitter 😉

Collapse
 
itsraghz profile image
Raghavan alias Saravanan Muthu

Congrats Abdisalan. I appreciate the thoughts of sharing your knowledge with a great intention that others dont need to suffer much. Keep it up.

Collapse
 
abdisalan_js profile image
Abdisalan

Thanks!