If you, like me, have been mystified by binary trees in your data structures journey, you might enjoy this little cheat sheet I built for myself to try to remember the differences in implementing depth-first searches in pre-, post-, and in-order traversal. Breadth-first search takes a little more set-up, but there’s only one method of traversal there to remember. While studying trees, I noticed that the code for all 3 DFS is super-similar except for tiny changes in the helper function that’s used to move from node to node.

This code is written in JavaScript, but it’s very simple and…

Anahit Gulian

Software engineer ^__^ NYC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store