Tree and Graph Data Structures Family Trees
Transcript from the "Family Trees" Lesson
>> 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.
>> 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.