Register to get access to free programming courses with interactive exercises

Introduction JS: Trees

A tree is one of the most common computer science data structures and a natural way to model certain domains. All people encounter trees (as a data structure) in one way or another, even those who aren't programming or interacting with computers in general. The most obvious example is the family tree, and a file tree when considering computers. HTML (like JSON, XML, and many others) also has a tree structure. Comments and product catalogs on websites are also trees. Any hierarchy is a tree by definition.

Example of a family tree

There is one very intriguing aspect associated with trees. A developer's ability to understand trees and work with them is directly proportional to their overall level. If it is easy for a developer to work with trees, then most likely have a pretty good understanding of coding, including when reading someone else's code. If, on the other hand, they don't know enough about trees, then they'll likely have more difficulty writing and analyzing code.

There are no new syntax or programming elements in this course that you haven't seen before in Hexlet courses. However, trees are more complicated topic above all because of the recursive nature of the trees themselves. You have to make your brain work properly, and this is probably the hardest part, you can't just read the theory and develop the understanding linearly. The only way is to practice and go through a trial-and-error process.

To better understand and memorize the learning material, our recommendations are the same as before:

  1. Be sure to practice all the code given in the theory yourself, on your local environment
  2. Use the debug print as much as you can. Log all data changes while the code is running
  3. Repeat the lessons from the JS: Functions course on recursion

In this short course, we'll get to grips with how trees work and how to use them. You won't see algorithms in this course as they're taught at university. This course has very different goals. We'll teach you how to work 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
Development of front-end components for web applications
10 months
from scratch
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.