Check out a free preview of the full Four Semesters of Computer Science in 5 Hours, Part 2 course:
The "Breadth-first Traversal Exercise" Lesson is part of the full, Four Semesters of Computer Science in 5 Hours, Part 2 course featured in this preview video. Here's what you'd learn in this lesson:

In the exercise you'll code the breadth-first traversal method to process the tree data structure into a flat array.

Get Unlimited Access Now

Transcript from the "Breadth-first Traversal Exercise" Lesson

[00:00:00]
>> Brian Holt: So in this one, I gave you a little helper tree up here, you can kinda see. And I also put it in alphabetical order so you can see, it should come out A, B, C, D, E, F, etc,, right, so, [COUGH] that's what your traversal should look like.

[00:00:18] You can see down here it expects it to be A, B, C, D, E, F, G.
>> Brian Holt: And here's what the tree looks like.
>> Brian Holt: Cool, and yeah, I'm gonna give you let's say, another 15 minutes to do this as well. And then, we'll come back and we'll do it together.

[00:00:44] Just to tell you how many lines of code I used to solve this.
>> Brian Holt: I think it's about 15-ish. No.
>> Brian Holt: A bit less than that. Let's go with closer to like nine, ten lines of code or something like that. More or less the same for the recursive and the iterative.

[00:01:08]
>> Brian Holt: Yeah, cool. So I'm gonna give you 15 minutes. And yeah, we'll come back and talk about it.