DFS vs BFS, When to Use Which?

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

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

  • @algo.monster
    @algo.monster  4 месяца назад +2

    Flowchart to decide which algo to use: algo.monster/flowchart

    • @OMNI_INFINITY
      @OMNI_INFINITY 28 дней назад

      Doesn't that dfs solution with max() simply return whatever branch had the node with highest number stored in it? What if the 2 branches are same length, but one of those contains 2 and other contains 3? Then it seems that "3" would be chosen when using that algo. That doesn't seem correct, because it's choosing based on the number stored, instead of depth.

  • @OMNI_INFINITY
    @OMNI_INFINITY 28 дней назад

    Thanks for posting that tutorial. So far 3 coding interviews had DFS. First one I think I completed successfully without knowing what DFS was (although could have been faster) and the interviewer said "Wow, it was as though invented DFS from scratch in this interview". Sadly wasn't hired to that position. Next was a color bucket photoshop style coding question, and next was a island sizes question or similar. Posting tutorials of all of those would be nice.

    • @algo.monster
      @algo.monster  26 дней назад

      Glad it helped! And yes DFS is the most commonly used interview algo!

  • @ShizDamn
    @ShizDamn 2 месяца назад +2

    You don't "need" to backtrack unless you're doing DFS, if you do BFS you can also get the depth and you don't "need" to backtrack

  • @ShivaPrasad-hm5lk
    @ShivaPrasad-hm5lk 3 месяца назад

    I restartwr leetcode after an year recently and startee somving knoy easy problema topic wise and as i was solving day 1 was good then day 2 i felt sruck so many times at evey problm matrix, subaaarrays, susbsets, priority quque, for now how do i like gwt good at these i want to but they make me uninterested just looking at them i feel stupid

    • @algo.monster
      @algo.monster  3 месяца назад +2

      Hey Shiva, it's very normal and it happens with almost everyone. My advise is instead of grinding more problems, learn the patterns first and it'll all make sense. Also start with the highest ROI patterns first, for a list check out: algo.monster/problems/stats

    • @ShivaPrasad-hm5lk
      @ShivaPrasad-hm5lk 3 месяца назад

      @@algo.monster does this channel have Instagram?

    • @ShivaPrasad-hm5lk
      @ShivaPrasad-hm5lk 3 месяца назад

      @@algo.monster I have taken the test and it is asking me to pay to learn can I do that without paying like I choosed the10 week plan and I want to like learn I like it seemed worth a try but then onclicking next it asked for subscription man I can't pay anything now is there anything free like this in ur site without subscription requirement and j will watch all videos in ur channel from now to catch up

    • @ShivaPrasad-hm5lk
      @ShivaPrasad-hm5lk 3 месяца назад

      @@algo.monster hey man thanks for the reply though

  • @sarahany477
    @sarahany477 12 дней назад +1

    There is really no need for the background music, it's just annoying and distracting!