Before we start building (planting?) our trees, let’s do a quick inventory of what we’ll need in our Python implementation. We’re going to make the class
- have a value
- have a reference to zero or more other
- can add a node as a child
- can remove a child
- can traverse (or travel through) connected nodes
Run the code to see a printed version of a company’s organization chart using a version of the
TreeNode class we’ll build in this lesson.
Bust out your green thumbs and click next when you’re ready to start implementing a tree in Python.