Check out a free preview of the full Tree and Graph Data Structures course
The "Exploring Data Modeling" 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 fields student ideas about how to implement a chatbot using linear data structures.
Transcript from the "Exploring Data Modeling" Lesson
[00:00:00]
>> Bianca Gandolfo: Who's really excited about what they came up with? Be proud.
>> Bianca Gandolfo: Anyone, you guys, let's hear it.
>> Speaker 2: So I was thinking of a top level.
>> Bianca Gandolfo: Guys, try to talk into the microphone.
>> Speaker 2: I was thinking of the top level array with three items. The first item is a string with a question.
[00:00:20]
The second item is a new array with three items that represents what you'd go to if you picked yes. The third item, is the new array with question, yes, no, options. If you picked no, it'd just be a deeply nested array of options.
>> Bianca Gandolfo: Okay.
>> Speaker 2: And it'd be a total mess.
[00:00:42]
>> Bianca Gandolfo: Yep, I like it.
>> Speaker 2: [LAUGH]
>> Bianca Gandolfo: I like it. You're thinking outside of the box. Outside of the array, so to speak, cool. Whoever wants to go. Everyone looks so excited.
>> Speaker 2: So if you just take the objects and flatten them out into an array and the yes or no is a pointer to another object, is that linear?
[00:01:08]
>> Bianca Gandolfo: Yeah, linear enough.
>> Speaker 2: Instead of nesting all the objects inside of one another just flatten it all out.
>> Speaker 3: And would you use if statements then for pointers, is that what you're saying, or?
>> Speaker 2: Just having either an index or an ID.
>> Bianca Gandolfo: These are technically, you can technically think of these as pointers to another object, too.
[00:01:29]
So it's very similar. So, still kinda nested, still kinda nested is fine. We're just exploring, yeah.
>> Speaker 2: I have all the objects in an array. And then when you want to access the left one or the right one, there's an equation that tells you which index you need to go to to find what would be the left or right child nominally.
[00:01:52]
>> Bianca Gandolfo: Hm, okay, I like that. In order to find the the yes or a no, you have to do some index math, cool. I think that's what you guys were saying over here, right?
>> Speaker 4: I think so, yeah.
>> Bianca Gandolfo: Yeah, very cool, sounds like a heap.
>> Bianca Gandolfo: Yeah, should look into that, that was a fun one.
[00:02:15]
Cool, anyone else?
>> Bianca Gandolfo: Awesome, so again that was just like a exploratory exercise. I don't want you to take whatever I say here as the hard and fast, only way you could possibly do this. You'll see that we always have to consider different ways of solving a problem.
[00:02:37]
And thinking about it, trying to think about it in a way that maybe doesn't necessarily make sense. Can also lead to interesting discoveries like a heap, binary heap, which is a data structure that you can use. To do the same thing. So this is a decision tree, right?
[00:02:58]
We have branching logic, decision trees can be used in all kinds of ways, like not only recommending breakfast, but also different logic.
>> Bianca Gandolfo: I'm blanking on a specific example, but they're all over. Anyone use a decision tree before? In my head I'm always using decision trees, like okay, if I do this, then that.
[00:03:31]
But has anyone used it at work or anything?
>> Bianca Gandolfo: I feel like it's kind of a product managey thing to draw out these decision trees or organizational logic. Anyway, try to think outside of the box. Whenever you're trying to solve a problem, when you come up with the first solution, stop yourself.
[00:03:56]
It's really hard, especially for me. My style is, I get excited because I figured out a solution and then I just want to jump in and code it right away. But I have to restrain myself and sit and think, okay, is there another way? To solve the same problem.
[00:04:17]
And doing this day to day where it doesn't have to be data structures and algorithms or an interview context. But say that you're creating an API for component. You're like, just do this. Just take a step back and think, is there another way I could do this, maybe think of a couple different ways.
[00:04:34]
Just to make sure that your way is the best way. Cuz you know they're gonna catch you in code review. They're gonna be like, actually, you can do it this way and then you're gonna have to redo it. So, just take a step back, consider the pros and cons of what you're doing, consider a different way of doing it.
[00:04:49]
And then, proceed.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops