Tree and Graph Data Structures

Depth First Search Exercise

Tree and Graph Data Structures

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

The "Depth First Search Exercise" 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 instructs students to code a method to perform depth first search on a graph.


Transcript from the "Depth First Search Exercise" Lesson

>> Bianca Gandolfo: Question.
>> Speaker 2: How do you make the connections then, if you're going to this is just as search it to?
>> Bianca Gandolfo: What connections?
>> Speaker 2: So you have the graph, you graph it, you gone through it all.
>> Bianca Gandolfo: Yeah, this graph exists already.
>> Speaker 2: Yeah.
>> Bianca Gandolfo: It has values in it, it has edges.

>> Speaker 2: So this is just a way to look through it for something.
>> Bianca Gandolfo: Mm-hm.
>> Speaker 2: And then once you find that thing, you would've stopped this. Let's say eight, you were looking for 8, so then you would stop at 8. You're done or 7, you would've stopped before.

>> Bianca Gandolfo: So you can, so that's more like a find?
>> Speaker 2: Yeah.
>> Bianca Gandolfo: That first search is gonna traverse through everything, every time. I mean you can, doing fine can be like a modified depth research. But when we talk about depth research, we're visiting every node in the graph.

>> Speaker 2: To do what? What is the, I guess-
>> Bianca Gandolfo: All kinds of fun stuff.
>> Speaker 2: Okay.
>> Bianca Gandolfo: Yeah, so you can use it to see if paths exist, if there's cycles, you might wanna validate the information in your graph. So there's all kinds of things. We might want to traverse it to get recommendations, that's what we're doing eventually.

Yeah, so once you have the stuff, you need to be able to look at it, so that you can do stuff with it. What that stuff is, you can get really creative with it.
>> Speaker 2: Yeah, so for a recommendation, so I guess, you're gonna go into that problem.

>> Bianca Gandolfo: We're gonna get there, yeah, yeah, but, yeah, I like where your head's at, okay. Are you guys ready? Take a stab

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