All Nodes Distance K In A Binary Tree - Performing Bidirectional Search On A Tree Using A Hashtable

Sdílet
Vložit

Komentáře • 465

  • @BackToBackSWE
    @BackToBackSWE  Před 5 lety +35

    Table of Contents:
    The Problem Introduction 0:00 - 1:10
    Going Through The Levels 1:10 - 3:00
    A Traumatic Flashback 3:00 - 3:29
    We Realize We Already Know How to Do This 3:29 - 3:56
    But...We Have A Problem 3:56 - 5:52
    A Hashtable Might Be Able To Help Us 5:52 - 7:14
    The Breadth First Search Walkthrough 7:14 - 13:24
    Time Complexity 13:24 - 13:29
    The Show Gets Hijacked By Ishan 13:29 - 13:51
    A Special Property of Trees 13:51 - 14:03
    An Example of The Property 14:03 - 14:41
    Space Complexity 14:41 - 14:55
    The Show Is Reclaimed 14:55 - 15:08
    Wrap Up: Subscribe & Validate My Existence 15:08 - 15:35
    Sort of Mistakes:
    5:57 -> O(1) does not mean immediate access. It is an asymptotic bound on how runtime scales with large input sizes.
    10:19 -> Many times I referenced the "seen" HashSet as a hashtable. I just mean it is a set of items with unique signatures.
    White Noise / Hissing On Audio:
    I know about it. I am still working to get the right sound settings right on my mic to make this disappear.
    The code for this problem is in the description. Fully commented for teaching purposes.

  • @lifealalexie
    @lifealalexie Před 3 lety +35

    I love how you explained things in the video, it was really easy to follow start to finish! The only complaint I have is the code isn't in the description like you said it would be.

  • @mrunaldave6781
    @mrunaldave6781 Před 3 lety +1

    How can your content be so good man? Video after video. The best. Take a bow.

  • @sammynochains3455
    @sammynochains3455 Před 4 lety +2

    This man is saving lives out here . I am subbed and hooked .. please keep uploading .. love your work and approach to problem solving and getting that across to people in a way that feels 'for a lack of a better word. Personal .

  • @Sky-nt1hy
    @Sky-nt1hy Před 3 lety +5

    Hey! I really do appreciate your videos. It makes everything super clear! You’re one of the best teachers so far. Keep being hyped!!
    From South Korea

  • @shashwatshukla6492
    @shashwatshukla6492 Před 3 lety +3

    Seeing that you have a Video on a Question that I'm Stuck on........gives me hope that I'll ever get stuck on this Type of Question Again.......Thanks Man....I Can't thank you enough......you've itched some questions and concepts into my Brain.

  • @AnjalySB
    @AnjalySB Před 4 lety +2

    I am a beginner in DS and algorithm. Have gone through 3 other channels. But I would say this is the best. Very brilliant way of conveying. Thank you

  • @tapasu7514
    @tapasu7514 Před 4 lety +2

    Love the way you start with your thought process, brilliant. Keep up the hard work

  • @dankokozar
    @dankokozar Před 5 lety +4

    You are brilliant, having a great gift of presenting, and also your video editing and timing is great (cutting out the right stuff). Subscribing!

  • @bestsaurabh
    @bestsaurabh Před 3 lety +2

    I never see your code, you explain the algo and I try to code it myself. Thanks for the great explanation

  • @grovervishal591
    @grovervishal591 Před 4 lety +2

    I love the way you explain this problem. I have solved this problem in the past but every time I struggle to traverse the parent nodes of start element. The way you add Hashmap to traverse the root is amazing. I dont think that I will forget this method now. Thanks for sharing this.

  • @rbragdish
    @rbragdish Před 3 lety +1

    Thank you so much for explaining with such clarity and articulation so that even a newbie like myself can understand how to go about solving these types of problems!

  • @spicy2112
    @spicy2112 Před 5 lety +2

    Thank you so much for the video. Crisp and clear. No bullshit. Love videos like these!! Keep up the good work!!

  • @jamestak1526
    @jamestak1526 Před 3 lety +1

    This is the beast channel I ever seen.THKS you and your team make the toppest resources available for us.

  • @manojrajasekar6035
    @manojrajasekar6035 Před 4 lety +3

    Such a Clear explanation of the thought process and the solution ! Great one as-usual

  • @abhilakshsharma1275
    @abhilakshsharma1275 Před 4 lety +3

    Such an ingenious approach ! Hats off to you mate. Keep posting :)

  • @pinakisaha9917
    @pinakisaha9917 Před 3 lety +3

    You literally put lot of effort to make us understand. Appreciate it a lot.

  • @yifanzhang1211
    @yifanzhang1211 Před 5 lety +3

    Your explanations are the clearest I have ever seen. I've been spending hours on this problem, then I understand the solution within 15 minutes by watching this. I appreciate you uploaded all these great explanations. I love them, I mean all of them.

  • @jhamukesh998
    @jhamukesh998 Před 5 lety +4

    You are the best tutor on youtube for dsa. Please make more and more videos to help us !!! Thanks a lot

  • @ishanmundra6891
    @ishanmundra6891 Před 5 lety +57

    Yo that man Ishan hella smooth

  • @kakashisenpai99
    @kakashisenpai99 Před 4 lety +3

    Was stuck in this qsn for almost a day . Thanks dude!

  • @who_fkn_cares
    @who_fkn_cares Před 4 lety +2

    Great walkthrough! Loving these videos.

  • @jamesfifth8479
    @jamesfifth8479 Před 3 lety +6

    really helpful this video, the clearest explanation in CZcams, thank you so much

  • @parthkhanna8542
    @parthkhanna8542 Před 3 lety +2

    Only a word can describe you as a whole....... and that word is AMAZING

  • @mrkyeokabe
    @mrkyeokabe Před 4 lety +2

    Was able to solve this problem on my own after listening to your great explanation. Thanks!

  • @vedantiyangar151
    @vedantiyangar151 Před 4 lety +2

    I kinda had doubts as to whether this will work with different nodes having the same value. And then I saw the code and realized you were storing the node references instead of the actual values. Thanks!

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +2

      Ah yeah, memory addresses have to to be unique.

  • @ricardobaeta3184
    @ricardobaeta3184 Před 3 lety +1

    using this to quick learn binary trees, super descriptive and clear, Great Work!

  • @AdwantGoutam
    @AdwantGoutam Před 4 lety +3

    Nice one. I like the simplicity and explanation. Thanks for that!

  • @caseyschneider1974
    @caseyschneider1974 Před 4 lety +12

    Firstly, thank you for your work. You are definitely the best on youtube doing these walkthroughs and a huge help to many.
    Second, could you also iterate through the tree and construct a new graph (list of edges), and then do a regular graph bfs to k distance? Although its an extra step it is still the same time complexity, so it is a trade off for a little more simplicity?

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +2

      "Could you also iterate through the tree and construct a new graph (list of edges), and then do a regular graph bfs to k distance?"
      yes
      "Although its an extra step it is still the same time complexity, so it is a trade off for a little more simplicity?"
      Yes, still O(|V|+|E|) as it is BFS. And also O(|V|) space. Just the "real" space usage will be more if we clone the whole graph.

    • @123aniruddhsiddh
      @123aniruddhsiddh Před 3 lety

      But that's not the question bro

  • @FreddGuillen
    @FreddGuillen Před 4 lety +2

    love this video! Thanks for share it. BTW the space and runtime complexity explanation was awesome! :) hehe

  • @JimmyCheng
    @JimmyCheng Před 5 lety +3

    Really good job, amazing stuff, keep it up!

  • @tingtingzhao7482
    @tingtingzhao7482 Před 2 lety

    Very clear explanation. The intuition and thought process helps me a lot!

  • @nayanikau2059
    @nayanikau2059 Před 4 lety +1

    Like your explanations because you focus on the intuition and approach behind reaching the solution. Also, you repeat important keywords quite a bit which is helpful in understanding a difficult/new approach. Keep up with the good work :)

  • @SUNILKUMAR-gy1je
    @SUNILKUMAR-gy1je Před 4 lety +1

    thank you ben you are amazing dude i was stuck with this for 4hours and u explained it in 15 minute's thanks again

  • @nelsonthekinger
    @nelsonthekinger Před 4 lety +1

    All the video was super cool to watch, but the humor again... stole the show!(at the end)
    Great Job!

  • @pkboolean
    @pkboolean Před 3 lety

    Great explanation, best I’ve seen. Keep it up!!

  • @ananya___1625
    @ananya___1625 Před 2 lety

    Crystal clear explanation!! Thanks a ton for your efforts and time

  • @suhasnayak4704
    @suhasnayak4704 Před 4 lety +5

    Amazing Explanation, thanks Benyam!!!

  • @raghavmittal5352
    @raghavmittal5352 Před 4 lety +1

    You are brilliant sir.Always come to your channel whenever got stuck

  • @mananarora5027
    @mananarora5027 Před 4 lety +1

    This concept was awesome !!!
    Great video

  • @srilekha9177
    @srilekha9177 Před 5 lety +1

    Great video. Clear explanation. Thanks a ton. Love you guys. You both made it simple.

  • @elenadontsova4688
    @elenadontsova4688 Před 4 lety +1

    Love the idea, great solution, thank you!

  • @sujithameriga7348
    @sujithameriga7348 Před 4 měsíci

    It was an amazing explaination. It made me think about other problems as well. Good job guys!

  • @vigneshwaranr680
    @vigneshwaranr680 Před 3 lety +2

    Thank you so much for the detailed explanation.❤️🙏

  • @shwetabhardwaj1131
    @shwetabhardwaj1131 Před 4 lety +8

    A perfect stop to every tricky problem, Thanks a ton!
    But is this the right choice to watch a video for a new topic?
    Basically, how do you suggest to watch your videos?

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +3

      We are releasing a new platform to keep everything organized today

  • @amitupadhyay6511
    @amitupadhyay6511 Před 2 lety

    the best explanation. Got the way in first 5 minutes itself.

  • @uppubhai
    @uppubhai Před 5 lety +1

    This guy is so much clear in his thought process

  • @vishwashdwivedi9469
    @vishwashdwivedi9469 Před 3 lety

    Thank you for such a great explanation !

  • @salimzhulkhrni1610
    @salimzhulkhrni1610 Před 5 lety +1

    thanks for the clear explanation. your code was even well commented & easily understandable. cheers!

  • @ish1285
    @ish1285 Před 4 lety +1

    So intuitive and amazing!

  • @anupkmr03
    @anupkmr03 Před 4 lety +2

    Awsome solution with great explanation technique. Thank you so much for the solution.

  • @xckevin8718
    @xckevin8718 Před 4 lety +1

    Thank you so much for this nice explanation. I should have subscribed your channel earlier. I'm having an Amazon interview next week but I feel that I'm not prepared yet.

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +1

      Nice, good luck, don't let the result determine your worth

  • @sophiejhones3575
    @sophiejhones3575 Před 5 lety +1

    This is awesome. Thank you!

  • @poojabennabhaktula4883

    Beautiful explanation, very grateful for your videos

  • @lalitkumarmehta1721
    @lalitkumarmehta1721 Před 5 lety +2

    thanks bro, for this awesome explanation. Keep making more videos

  • @sye119
    @sye119 Před 3 lety

    great explanation and ending, thanks Benyam!

  • @quantum598
    @quantum598 Před 3 lety

    Benyam had to join the SWE website cause the content is amazing...BUT REAL TALK in an interview where you spent 20-30 minutes on behavioral, it would be pretty wild to get this!!! 1 main function with 3 helpers approx 80+ lines of code (for us java peeps ) , 'i cry everytim'

  • @nandhiniperiyasamy4782
    @nandhiniperiyasamy4782 Před 5 lety +3

    Awesome explanation . Thank you so muchh

  • @xiaoxiao5333
    @xiaoxiao5333 Před 5 lety +2

    Thanks very much for the awesome videos and detailed explanations. Really loved the series.
    Wanted to ask if you can also make a video to explain the method using DFS to solve this problem? Thanks!

  • @AmolGautam
    @AmolGautam Před 2 lety

    Thank you. Very well explained

  • @eyeamkd
    @eyeamkd Před rokem

    That moment of happiness when you come to know that there's a BTBSWE solution for the problem that you're currently stuck with!

  • @tulikamal
    @tulikamal Před 5 lety +2

    Excellent explanation! Please make more videos on the various algorithmetic problem

  • @sai2ramya
    @sai2ramya Před 2 lety

    great great great explanation!!

  • @avoo1d
    @avoo1d Před 4 lety +1

    I love it, very brief explanation, much better than looking at the discussion of leetcode Lol

  • @suyashsavji5189
    @suyashsavji5189 Před 3 lety

    Thanks a lot for this!

  • @yuhaoliao3270
    @yuhaoliao3270 Před 2 lety

    Thanks! This video is really helpful for me to prepare the coding interview!

    • @BackToBackSWE
      @BackToBackSWE  Před 2 lety

      Thank you, glad you liked it 😀
      Do check out backtobackswe.com/platform/content
      and please recommend us to your family and friends 😀

  • @sunnyday12131
    @sunnyday12131 Před 2 lety

    great explaination !

  • @Mai_Bharatwaasi
    @Mai_Bharatwaasi Před 4 lety +1

    Thank-you!! video is helpful

  • @tejaspb24
    @tejaspb24 Před 5 lety +1

    Thank you very much for that easy explanation.

  • @anuragv400
    @anuragv400 Před 3 lety

    Great explanation !! 🤩🤩🤩🤩

  • @qqq11811
    @qqq11811 Před 5 lety +1

    Very helpful. Thank you very much!!!

  • @anuragagnihotri5238
    @anuragagnihotri5238 Před 3 lety

    You explanations are simple and easy to follow

  • @prachurjyabasistha4682
    @prachurjyabasistha4682 Před 4 lety +1

    Man!...You are GOD!!..Again Best explanation on the entire internet!!

  • @jaydhanwant4072
    @jaydhanwant4072 Před 3 lety

    I like how you squeeze your eyes to emphasise something :D

  • @sahukarinaveenkumar3188
    @sahukarinaveenkumar3188 Před 4 lety +1

    The way you explain the Concepts are very clear... But it was very helpful if u explain the problem along with some pseudo code😀

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +1

      We have a code sample up but the repository is deprecated - we only maintain backtobackswe.com now.

  • @thanga2317
    @thanga2317 Před 5 lety +2

    Thank you Mr.Perfect :)

  • @techykush7192
    @techykush7192 Před 3 lety +1

    thank u so much sir and entry of ben is just awesome 🤣🤣

  • @Dyslexic_Neuron
    @Dyslexic_Neuron Před 3 lety +1

    Awsome bro ! Good explanation

  • @ketankhandelwal8626
    @ketankhandelwal8626 Před 3 lety

    Superb Explanation.

  • @AleDSan3
    @AleDSan3 Před 3 lety

    You are a legend!

  • @shreejitnair2174
    @shreejitnair2174 Před 4 lety +1

    Man what a terrific explanation.

  • @shivanandrajput4548
    @shivanandrajput4548 Před 5 lety +1

    wow simply awesome Thanks !!!!

  • @VinaySingh-ud1kp
    @VinaySingh-ud1kp Před 4 lety +1

    Thank you so much!

  • @satishshingade8514
    @satishshingade8514 Před 3 lety +1

    Please continue uploading videos you teach really good..RESPECT+++

  • @deathstrokebrucewayne
    @deathstrokebrucewayne Před 4 lety +1

    Okai....Concluded....You are awesome :D

  • @vineetrathee7334
    @vineetrathee7334 Před 4 lety +1

    GREAT explanation sir.

  • @alamatel
    @alamatel Před 4 lety +1

    Amazing explanation.

  • @taiwan.1
    @taiwan.1 Před 4 lety +1

    very amazing explanation. again. thanks.

  • @SoumikNandi
    @SoumikNandi Před 4 lety +1

    Simply the best!

  • @sunginjung3854
    @sunginjung3854 Před 5 lety +1

    This is a great video. Very clear and easy to understand explanation. Why don't you make a playlist where you organize your videos in order(e.g. 1st video to watch and so on) for people to follow?

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety +1

      people have suggested this but....1.) I can't make anymore playlists...I've hit the cap....and 2.) I don't think there is any order...it is just whatever topic you are weak at...and you practice that....I think that's the optimal strategy....there can be no master order of questions because that ignores that everyone is generally different and more or less adept at different categories to different degrees

  • @rahulchudasama9363
    @rahulchudasama9363 Před 4 lety

    Awesome explanation , you saved my day

  • @cmubill
    @cmubill Před 2 lety

    Very clear explaination. Hope you can make an DFS explain on this!

    • @BackToBackSWE
      @BackToBackSWE  Před 2 lety

      Thank You, Glad you liked it.
      Do check out backtobackswe.com/platform/content
      and please recommend us to your family and friends :)

  • @yuktikhantwal2342
    @yuktikhantwal2342 Před 4 lety +1

    you guys are brilliant

  • @raksstrife1233
    @raksstrife1233 Před 5 lety +2

    Hey Ben, great video! Keep up the good work. I have a request, would you please recommend a way to get good at Object Oriented design?

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety +3

      Eh...I mean, that's a hard thing to answer. Like...how did doctors get good at doctoring? It'd be a long history of study and learning. So many uncountable days absorbing information.
      All you have to do is practice. Practice coding, read books, watch CZcams videos.
      A great book I have read and recommend is called "Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C. Martin

  • @Randomtaker
    @Randomtaker Před 3 lety

    Thank you dude. First, i thought i should use hashmap for storing distance of nodes from the target node but ur tricked help to map parenting of node that help me

  • @ankuragarwal4014
    @ankuragarwal4014 Před 5 lety +1

    It's really the best resource to learn

  • @ankitkaushal442
    @ankitkaushal442 Před 3 lety

    nice explanation

  • @kakoli960
    @kakoli960 Před 3 lety

    Thank you Sir 💞

  • @raviverma-tj6dn
    @raviverma-tj6dn Před 4 lety +1

    Extraordinary explaination Sir

  • @ankuragarwal4014
    @ankuragarwal4014 Před 5 lety +1

    Awesome explanation