Coding Challenge #68: Breadth-First Search Part 1

preview_player
Показать описание


Other Parts of this Challenge:

References:

Videos:

Related Coding Challenges:

Timestamps:
0:00 Introducing today's topic: Breadth First Search
2:42 6 Degrees of Bacon
4:45 Node object
6:40 Let's Code!
8:02 Graph Object
9:44 Read the data
12:28 Attach a method to the graph object using prototype
16:52 Add an edges function
17:38 Determine whether actor node already exists

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#breadthfirstsearchalgorithm #sixdegreesofkevinbacon #javascript #p5js
Рекомендации по теме
Комментарии
Автор

Just a random thank you... Both your enthusiasm & teaching methodology make a world of difference to learning many of these concepts. It truly is addictive...

mannerisms
Автор

You're so excited, this is great! (also paused the video and spent 5 minutes playing on oracle of bacon. I don't know why)

cl
Автор

Google also has this "easter egg" where you can search for "Bacon number" followed by the actor's name for similar results.

theentirepopulationofsyria
Автор

For anyone who's interested, here is some benchmarks of Breadth-First Search implemented in a few languages: (averages over a few runs)

nodejs (v6.10.3) : 0m0.065s
c++ (clang version 5.0.0) : 0m0.003s
go (go1.9.1) : 0m0.002s

mworld
Автор

You're such a great teacher! You make learning this stuff interesting. A+

Andyman
Автор

Again, at 18:30, you need to put line 27 inside the condition block. Because Graph.addNode does two things, push the node to nodes and add it to the set. While the latter makes no difference if the node is added twice, the former will create duplicates within the nodes array.

yanfoo
Автор

you're not stiffman Daniel you are stuff man

jaiveer
Автор

I recently started using js's object oriented programming features and i like it. You can do sth like this:
class Node {
constructor(something){
this.value = something;
}
}
node = new Node(value)

Tymon
Автор

Hey Daniel!

Thank for these amazing videos. I love your enthusiasm. I need that in order to learn. Almost done with my CS degree but its great to see these implementations. I just bought the book Grokking Algorithms that you mentioned. Cannot wait to read it. Thank you for these videos. I'm excited to watch the rest of the series!

Regards,
Jose Ortiz

MrMasterRhythm
Автор

Can you do a video on dynamic programming?

NinjaKyou
Автор

Amazing, Mainting an instance variable for visited nodes was a good idea, it prevents key errors in hash maps, Great Thanks!

mandeepubhi
Автор

At 19:16, you can simply write : if (!actorNode) { ... } It is not only the JavaScript-way of testing "truthy" values, it prevents the case where null !== undefined. (Also, === is preferred to == because JavaScript's loose type syntax (ex: 0 == '' is true, but 0 === '' is false)

yanfoo
Автор

I love watching these even though I'm absolutely terrible at programming, most if not all of it is jibberish to me :D

danp
Автор

I think the graph.addNode(actorNode) should also go inside the if (actorNode == undefined) condition, otherwise you are pushing the actor node
multiple times in your this.nodes array in graph object.

manotoshroy
Автор

This was the most entertaining video I've ever watched

davidli
Автор

Great video, super helpful, thank you!

nathalia_adeline
Автор

searches himself for k.bacon. lolol, you are fun!

greenie
Автор

I don't know if this has happened before but this is the first time I've noticed it. Your hair slightly transparent and it keeps putting me off xD

Jacobjghughes
Автор

Is there an updated version of this in 2021?

TheNamesJT
Автор

Man you look like the Professor from Money Heist !

akosp-h