Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Tree Data Structure in JavaScript

    javascriptJavaScript

    A tree data structure is a graph without any cycles. I can hear you saying, "Kyle, that's a super helpful explanation," with a healthy dose of sarcasm already. "No cycles" means that no three nodes create a circuitous path. In a tree, nodes have a single parent node and may have many children nodes. They never have more than one parent nor point to any siblings.

    The most common tree structure you see is a web page. The underlying structure is often called the "DOM tree". The html element forms the root of our tree, with children of head and body, so on and so forth. In this lesson, we'll create a quick example of a DOM tree with our tree data structure.