Check out a free preview of the full Tree and Graph Data Structures course
The "Breadth 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 breadth first search on a graph and answers questions about its implementation.
Transcript from the "Breadth First Search Exercise" Lesson
[00:00:00]
>> Bianca Gandolfo: We are going to take a stab at implementing breadth first search. Yeah.
>> Speaker 2: Can you go high level again for that one?
>> Bianca Gandolfo: Yeah.
>> Speaker 2: Before you wanted to go, just go.
>> Bianca Gandolfo: Yeah, absolutely. So high level breadth first search.
>> Speaker 2: No, it's a depth.
>> Bianca Gandolfo: Yeah, for sure.
[00:00:19]
Breadth-first search is going to search all of the closest adjacent nodes before the further ones, or depth-first is going to go to the furthest ones first and then back and then the furthest ones and back. So it's the order-
>> Speaker 2: How does it go to the next one?
[00:00:39]
So go up or down and then over, or?
>> Bianca Gandolfo: For a breadth-first?
>> Speaker 2: Yeah.
>> Bianca Gandolfo: Breadth-first is going to go in rings. So it's gonna be, you're gonna have your center. And then you have the ones that are adjacent. And then you have sort of the second degree ones.
[00:00:55]
And then it spirals out like that.
>> Speaker 2: And does it fill a stack like how it kind of did that with the other one, or?
>> Bianca Gandolfo: Fills a queue.
>> Speaker 2: A queue.
>> Bianca Gandolfo: Yeah, that's the primary difference between this, is one uses a stack and one uses a queue.
[00:01:11]
Yeah, and that changes the order that we visit, but it's largely the same.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops