Check out a free preview of the full Tree and Graph Data Structures course

The "Family Trees" Lesson is part of the full, Tree and Graph Data Structures course featured in this preview video. Here's what you'd learn in this lesson:

Bianca presents an example of a tree data structure representing a family and analyzes its structure.

Preview
Close

Transcript from the "Family Trees" Lesson

[00:00:00]
>> Bianca Gandolfo: So we talked a little bit about how this is like a family tree. Prior, we were looking at using objects to represent the nesting. Here we have three people, we have a mother, a son and a daughter. And we can see that we're creating a tree data structure here through the children property, which holds a reference to the son and the daughter in or no way.

[00:00:26]
So again, when we are working with our trees, we can use objects, messing with objects, we can use arrays. Why will we use an array instead of an object?
>> Speaker 2: I had like a risk is of the index of you can kind of find the index of whatever object you're looking for pretty quickly with an array.

[00:00:47]
>> Bianca Gandolfo: Yeah, so there are some like array methods that are useful like index love, maybe even a length, right? Maybe you wanna know how many children there are.
>> Speaker 2: When order matters.
>> Bianca Gandolfo: When order matters, right? Maybe the son is older or younger than the daughter and we want to arrange it by like birth order or something like that.

[00:01:08]
Yeah, absolutely, so just something to think about. There are many ways. Think about when you are implementing your tree right now using this exercise.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now