Coding Challenge #68: Breadth-First Search Part 1

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

Комментарии • 106

  • @mannerisms
    @mannerisms 7 лет назад +3

    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...

  • @Andyman2340
    @Andyman2340 4 года назад +5

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

  • @cl3375
    @cl3375 6 лет назад +11

    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)

  • @yanfoo
    @yanfoo 7 лет назад +1

    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.

  • @MultiPawns
    @MultiPawns 7 лет назад +9

    You are an artist. Best artist :P

  • @mandeepubhi4744
    @mandeepubhi4744 4 года назад +1

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

  • @yanfoo
    @yanfoo 7 лет назад

    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)

  • @mworld
    @mworld 7 лет назад +1

    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

  • @MrMasterRhythm
    @MrMasterRhythm 7 лет назад +3

    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

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +3

      Glad to hear!

    • @xynyde0
      @xynyde0 6 лет назад

      You'll be disappointed, trust me pal.

  • @davidli2522
    @davidli2522 7 лет назад +3

    This was the most entertaining video I've ever watched

  • @NinjaKyou
    @NinjaKyou 7 лет назад +37

    Can you do a video on dynamic programming?

    • @ssuriset
      @ssuriset 4 года назад +1

      You found a bug I see.

  • @jaiveer7701
    @jaiveer7701 7 лет назад +7

    you're not stiffman Daniel you are stuff man

    • @jaiveer7701
      @jaiveer7701 7 лет назад +2

      I'm a great fan of you man

    • @CarlinoGonzalez
      @CarlinoGonzalez 7 лет назад +4

      DealerMark Bikes haha we all are fans of "stuff man" ☺️

  • @theentirepopulationofsyria
    @theentirepopulationofsyria 7 лет назад +5

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

  • @matthewmashiane8995
    @matthewmashiane8995 6 лет назад +2

    These videos are awesome. Thank you.

  • @Tymon0000
    @Tymon0000 7 лет назад +4

    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)

  • @nathalia_adeline
    @nathalia_adeline 6 лет назад +3

    Great video, super helpful, thank you!

  • @marktbot
    @marktbot 4 года назад

    This is amazing-thank you!

  • @danp2596
    @danp2596 7 лет назад +34

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

    • @kalebdesousa355
      @kalebdesousa355 7 лет назад +1

      Right there with you Dan P

    • @danp2596
      @danp2596 7 лет назад

      I want to learn so bad but I'm struggling to find the motivation because I'm so bad at it atm lol

    • @TheHpsh
      @TheHpsh 7 лет назад

      well, you might try other languages then javascript, some people like python, some like ruby, some like C, i like something called livecode.

    • @CarlinoGonzalez
      @CarlinoGonzalez 7 лет назад +4

      Hey you could start learning to program! It's an amazing world. I saw you said you need motivation, I used to be like you a few years ago! If you need help or advice let me know :)

    • @TheHpsh
      @TheHpsh 7 лет назад +1

      saw that you had some C videos, i like that as a old turbo C programmer :-)
      wish a was better in english and not a boring old guy, making tutorial in programming looks like a great thing to do

  • @manotoshroy9934
    @manotoshroy9934 4 года назад

    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.

  • @architnaik5096
    @architnaik5096 7 лет назад

    I love Your Videos A lot specially coz of regular uploads!!

  • @abhishekmazumdar2072
    @abhishekmazumdar2072 4 года назад

    @17:53 the Time complexity jumps n^2. Any other ways to do this?/

    • @AjaSiva
      @AjaSiva 4 года назад +1

      Actually reading from hash table is O(1) unless there are collisions. So time complexity is still in order of n not n^2 .

  • @TheNamesJT
    @TheNamesJT 3 года назад

    Is there an updated version of this in 2021?

  • @CSRocks
    @CSRocks 7 лет назад

    great content as always!

  • @greenie62
    @greenie62 4 года назад

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

  • @minhta9449
    @minhta9449 6 лет назад

    This is how I visualize a graph. Free to use: editor.p5js.org/tvm389/sketches/BkZdUgSgE

  • @АлексейГусар-ф9й
    @АлексейГусар-ф9й 6 лет назад

    This is great!! Thank you!

  • @nadavw3
    @nadavw3 7 лет назад

    In sketch.js: graph.addNode should be inside the if

  • @nazibabrar1824
    @nazibabrar1824 4 года назад

    Can anyone help me with the json file? Do I have to type it watching the video? That one is missing from the github repo

  • @Jacobjghughes
    @Jacobjghughes 7 лет назад +8

    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

    • @igotapochahontas
      @igotapochahontas 6 лет назад

      Jacob JG lol. His green screen skills are so much better than mine.....but now it's all I can see too...

    • @mohammadrezaamjadian7100
      @mohammadrezaamjadian7100 6 лет назад

      what have you done...

  • @chibibobo
    @chibibobo 7 лет назад

    My copy of Grokking Algorithms is in the mail, looking forward to it!

  • @lorenzm7412
    @lorenzm7412 7 лет назад

    can u maybe in your intellegence and learing or as a coding challenge do a simulation of an ecosystem? maybe with a genetic algorithm or some kind of other algorithm i dont know yet, that u can teach in the video :) also thanks for all the things i learned through you

  • @ajaysaravade5213
    @ajaysaravade5213 5 лет назад

    Can you solve ICPC ASIA World Final 2014 D(Game Stategy) problem, please make video on that

  • @churchers
    @churchers 7 лет назад

    I guess this stuff has already been fixed but you don't need to add the actor node to the graph if it's returned by getNode. Also calling the argument in getNode 'actor' is a bit ugly as that object can be used to store anything, not just actors. Something like 'key' would make more sense.

  • @williamv2520
    @williamv2520 5 лет назад

    var movies = data.movies; is coming out as null/undefined for me. Am I missing something?

  • @apex12122
    @apex12122 2 года назад

    Any links to the code and the .json file so I can code along ?

    • @TheCodingTrain
      @TheCodingTrain  2 года назад

      Everything is here! thecodingtrain.com/challenges/68-breadth-first-search

  • @psyneur9182
    @psyneur9182 7 лет назад +1

    common use some ES6 features. I want to see class {} notation!

  • @kumaiyavlogs5020
    @kumaiyavlogs5020 7 лет назад

    which application you are using so that i can start immediately pls help

  • @AirTimeEh
    @AirTimeEh 7 лет назад

    great teaching

  • @beenbeen130
    @beenbeen130 7 лет назад +2

    Breath-first VS. Death-first

  • @geoffwagner4935
    @geoffwagner4935 Год назад

    hm still no bacon links tho

  • @mintyplays4682
    @mintyplays4682 7 лет назад

    1:08 did Alice just move?

  • @ali_gaming3190
    @ali_gaming3190 7 лет назад

    What is the name of the book and the author?

  • @jamerack4656
    @jamerack4656 6 лет назад

    Hey, I don't know if you respond to comments on old videos, but I had some confusion about why you did the movies as their own nodes rather than the edges between actors. That's the way I thought it would be done and I'm confused why you chose to have movies be their own nodes. Thanks!

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +1

      This is a great question and I think my decisions here were somewhat arbitrary just to demonstrate the idea of BFS.

    • @jamerack4656
      @jamerack4656 6 лет назад

      The Coding Train okay, thanks for the reply! Your videos are a big part of what made me want to go into computer science and I really appreciate it

  • @trebturner
    @trebturner 7 лет назад

    Love these videos! By the way, what color theme do you use for your Atom editor? It is very pleasing to the eye holes.

    • @carneloot
      @carneloot 7 лет назад +1

      I think it's the default theme

  • @ryacdebarros1904
    @ryacdebarros1904 7 лет назад

    Hi. Just want to say I love you and do you do live streams? If so when and where? I would love to watch you live but I don't get any notifications and stuff so please help me out anyone?

  • @Nola1222Piano
    @Nola1222Piano 7 лет назад +2

    What did you study?

    • @CarlinoGonzalez
      @CarlinoGonzalez 7 лет назад

      He's a professor at the Interactive Telecommunications Program at NYU's Tisch School of the Arts :)

    • @CarlinoGonzalez
      @CarlinoGonzalez 7 лет назад +2

      Oh, don't mention him "Computer Science" ;) haha

  • @SketchStack
    @SketchStack 7 лет назад

    hey can you please make some great "create js" tutorials as you made p5.js tutorials (those videos is very helpful and awesome)

  • @corporateexplorer6544
    @corporateexplorer6544 5 лет назад

    Can you please provide the movies json

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Everything should be here! If something is missing please file a github issue. thecodingtrain.com/CodingChallenges/068.1-bfs-kevin-bacon.html github.com/CodingTrain/website/issues

    • @warhammer48
      @warhammer48 Год назад

      @@TheCodingTrain its saying page not found now

    • @TheCodingTrain
      @TheCodingTrain  Год назад

      @@warhammer48 the website changed! It's here now: thecodingtrain.com/challenges/68-breadth-first-search

  • @poofick
    @poofick 7 лет назад

    you picked quite complicated example with movies and actors. Would be much easier to explain BFS with a simpler nodes ( say a subway stations ) IMHO. Still like your videos, and thanks for your time recording them!

  • @akosp-h8057
    @akosp-h8057 4 года назад

    Man you look like the Professor from Money Heist !

  • @ThePieas
    @ThePieas 5 лет назад

    loadJSON() does not work on file protocol

    • @ThePieas
      @ThePieas 5 лет назад

      @Jose Garza Yes .. loadJSON() works on live-server.. You can install the npm package

  • @Артём-д4ж5у
    @Артём-д4ж5у 6 лет назад

    where I can find file kevinbacon.json ?

    • @SamBerryBeresford
      @SamBerryBeresford 6 лет назад

      You don't even need to have the file if you use:
      data = loadJSON("raw.githubusercontent.com/CodingTrain/website/master/CodingChallenges/CC_068_BFS_kevin_bacon/kevinbacon.json")

    • @yuqingwang3593
      @yuqingwang3593 6 лет назад

      github.com/nature-of-code/NOC-S17-2-Intelligence-Learning/blob/master/week1-graphs/P2_six_degrees_kevin_bacon/bacon.json

  • @geoffwagner4935
    @geoffwagner4935 Год назад

    little cup of tea? no, i carry my used coffee and espresso grains out in 4lb tubs. definitely get good coffee, i don't believe in cheap or dark. i like the full bean as lightly cooked as possible, has the most caffeine. and quality bean. i like butterflies from my espresso. cheap coffee is always a waste of money. and i learned what it's like to almost die from not enough sugar they had to give me a tube of sugar paste to get my heart normal, i don't buy zero sugar anything anymore. lots of sugar in my coffee, low sugar cults are the most dangerous thing i've seen now. i buy monsters and other stuff not just for vitamin but even more so for the sugar, we really need that stuff. much more so with protein and exercise said my extra protein is why i needed more sugar. takes sugar to process protein too. coffee is a very magical bean. and a $350 7 stage purifier with reverse osmosis and add 7 minerals back in. it's what you see everyone try, buying mineral packets for espresso water, mines what they are really after tho, xD pulls out the chlorine and fluoride with carbon filtering from coconut shell and at least 600+ more chemicals. sometimes tea, more often coffee and espresso.

  • @brolyshop6822
    @brolyshop6822 3 года назад

    Does this man know how much effect he make to peopel lives ?

  • @svitirur1665
    @svitirur1665 5 лет назад

    coding challenge is to do it in vanilla js

  •  7 лет назад

    google also gives you bacon numbers :D

  • @sck3570
    @sck3570 7 лет назад +3

    Shiffman => use some webpack and es6 style of classes or typescript etc ... it's more fun than raw vanilla js

  • @jacksonkr_
    @jacksonkr_ 7 лет назад

    Lol you forgot the correct method declaration on node.js:9 @ 16:44 but when you switched back to the file @ 18:37 it was magically fixed! Nice try Mister Coding Train ( ;

  • @iMaCH
    @iMaCH 7 лет назад

    you remind me of mat from achievement hunter XD

  • @ajanibilby
    @ajanibilby 7 лет назад

    This video came out on the day I handed in an assignment of which did a degrees of separation for wikipedia XD
    Shameless promotion :p > github.com/Hobgoblin101/Wiki-Web/releases/tag/v1.0.0

  • @bhaumikjoshi2572
    @bhaumikjoshi2572 4 года назад

    Kalman filter

  • @IbakonFerba
    @IbakonFerba 7 лет назад +2

    The inventor of the gif format himself pronounces it jif, so it's jif

    • @jchevertonwynne
      @jchevertonwynne 7 лет назад +2

      no. if everyone says it as gif, then it is gif.
      like how americans and brits say tomato. in america the way to say it is different from in england, regardless of how it was originally said

  • @joostvanrens
    @joostvanrens 7 лет назад

    it's gif.

  • @RicardoBuquet
    @RicardoBuquet 5 лет назад

    I really dont think using that platform is helpful. You spend time in things not related to the problem . Causing people with less context to have a bunch of really not useful information, and making them to lose the focus.
    You shoud do this in only one javascript file where all the pieces are together and are easy to relate.
    my 2 cents.

  • @kzakaria91
    @kzakaria91 5 лет назад

    kevinjason.bcon

  • @PaulJaworski
    @PaulJaworski 5 лет назад

    The "G" in Gif is soft. It's pronounced like the peanut butter.

    • @MadMilo91
      @MadMilo91 5 лет назад

      Stop trying to make it .jif, it's not going to happen!

  • @bhaumikjoshi2572
    @bhaumikjoshi2572 4 года назад

    Kalman filter

  • @bhaumikjoshi2572
    @bhaumikjoshi2572 4 года назад

    Kalman filter

  • @bhaumikjoshi2572
    @bhaumikjoshi2572 4 года назад

    Kalman filter