Tree and Graph Data Structures

Linear vs Non-Linear Data Structures

Bianca Gandolfo

Bianca Gandolfo

Thumbtack
Tree and Graph Data Structures

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

The "Linear vs Non-Linear Data Structures" 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 distinguishes between linear and non-linear data structures and highlights strengths of trees and graphs, which are non-linear.

Preview
Close

Transcript from the "Linear vs Non-Linear Data Structures" Lesson

[00:00:00]
>> Bianca: So we have our linear stuff, are we feeling comfortable with that? Because we're going to like walk off the cliff soon to our non-linear data structures and let's just do a quick comparison here. So in general we talked about linear being ordered. They're attached one after another.

[00:00:21]
And we can form a lot of intuitions about that because we reason about things like that in real life, whereas nonlinear data structures can be a little more complicated because the relationships between nodes can be multitudes, right? So when we talk about graphs, you'll see that a graph can have many connections between nodes and different characteristics of those relationships can affect all kinds of things like the different types of operations you can do, the time complexity of those operations, etc.

[00:01:00]
The cool thing about nonlinear data structures though is that we can model complex things that we can't really model in our head, right? And that's where the value comes, is abstracting these down to something simple, then applying it to a huge data set that we can't reason about it all.

[00:01:18]
And then coming up with some really interesting insights on that data. So that's cool. I like that. It makes it interesting. Traversing is a little bit different. We're going to use a lot of loops when we're talking about linear data structures, just regular four-loops. When we start talking about non-linear data structures, we start to get into the recursion.

[00:01:41]
Who here feels really good about recursion? Are you guys serious?
>> Speaker 2: [LAUGH]
>> Bianca: I'm just kidding. Cool, that's awesome because we're gonna talk a lot about recursion. We'll break it down. If you're feeling like recursion is a little tough hopefully, this will help. I also have other videos here on front end masters that go super in depth on recursion.

[00:02:09]
In terms of implementing the data structure, when I say implementing the data structure I mean the insert and remove pieces of it. That is a bit more complex for nonlinear data structures. Just because we're going to have, you can have multiple relationships. We can have hierarchical data. And there also might be some properties we need to observe.

[00:02:32]
Like for a binary search tree. Whenever we're inserting or deleting. There's certain rules we need to follow and check. The levels, linear, you're gonna have single level. Non-linear, as you might expect, we're gonna have multiple levels. So we're gonna have things like height and depth and children and parents and things like that to reason about.

[00:02:55]
And we know the examples right? Tree and graph for non linear and our array base or link list based on data structures we discovered.

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