Register to get access to free programming courses with interactive exercises

Introduction Python: Trees

A tree is one of the widespread data structures in computer science and a natural way to model certain subject areas. Everyone will encounter trees as a data structure in one form or another, even if they're not into computers or programming in general. The most obvious example is a family tree, and if we're looking for something more up our street, a file tree.

HTML, JSON, XML, and many others have a tree-like structure. Comments and product catalogs on websites can also be tree-like. Any hierarchy is a tree by its definition.

There is one curious aspect associated with trees. The level of understanding of trees and the ability to work with them correlates with the developer's skills. If it's easy for a developer to work with trees, then they'll be able to understand code quite well. Otherwise, they'll have more difficulties with writing and analyzing code.

In this course, there'll be no new syntax or any programming elements that you haven't studied in Hexlet before this course. However, the topic of trees is more complicated than other topics due to the recursive nature of the trees themselves. We should switch our brains onto trees — this is most likely the most challenging part. It is something that you can't just learn by reading the theory. Only practice and experimenting can help with this.

We want to simplify the understanding and memorizing, so our recommendations are the same:

  1. Be sure to repeat all the code given in theory locally on your computer
  2. Don't forget to print as much as possible to help you debug
  3. Display all data changes while the code is running

In this short course, we'll dive into the topic of trees and learn how to work with them. What won't be in this course is algorithms in the same way as you might see at university. This course has completely different goals. It teaches working with recursive data structures through tree recursion.


Are there any more questions? Ask them in the Discussion section.

The Hexlet support team or other students will answer you.

For full access to the course you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

Bookmate
Health Samurai
Dualboot
ABBYY
Suggested learning programs
profession
new
Developing web applications with Django
10 months
from scratch
under development
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.