Learn
Trees: Python
Trees Introduction
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 TreeNodes
.
TreeNodes
:
- have a value
- have a reference to zero or more other
TreeNodes
- can add a node as a child
- can remove a child
- can traverse (or travel through) connected nodes
Instructions
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.