Log in from a computer to take this course

You'll need to log in from a computer to start Learn Complex Data Structures. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?