0-1 BFS: What is it, How to Code with Example Question | CP Course | EP 80

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

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

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd 3 года назад +35

    The visualization part of your code make you stand out of all the other instructor. Really it is quite easy to understand with the explanation . Thanks a lot for making such a great content and giving your time and energy to the community.

  • @shivampatel8850
    @shivampatel8850 2 года назад +2

    You are the best teacher because till now I did not find such a useful play list on graphs, as I face lots of difficulty in this topic but you cleared my all doubts. Thank-you luv bhai..

  • @aishwaryasingh2021
    @aishwaryasingh2021 3 года назад +6

    Thank You for explaining so nicely and for walking us through the implementation. Also, talking about log N factor that would come in picture if Djkstras is used was a masterstroke.

  • @YogeshShinde31
    @YogeshShinde31 2 года назад +4

    We might visit the node multiple levels but the first time you visit it , there is chance there is another edge with 0 wt at same level. Next encounters at different levels won't be processed as it will only increase the level of node. defeating shortest path💛

  • @iamnoob7593
    @iamnoob7593 3 месяца назад

    Got it , Took some time to explain myself how things are working here to find shortest path. Understood , Thank you.

  • @tanishgupta7879
    @tanishgupta7879 Год назад +1

    11:23 This question is similar to Leetcode question - 1466. Reorder Routes to Make All Paths Lead to the City Zero.

  • @jonayedmohiuddin538
    @jonayedmohiuddin538 Год назад +2

    Your explanation is great!

  • @PoojaSharma-nt3ge
    @PoojaSharma-nt3ge 7 месяцев назад

    One of the most underrated but best instructor on RUclips. Your content is a hidden gem 💎💎

  • @AdityaSingh-ql9ke
    @AdityaSingh-ql9ke 3 года назад +2

    I was trying this question and my friend told to use this method...I didnt understand..thank god u posted a video on this.

  • @itz_me_imraan02
    @itz_me_imraan02 3 года назад +6

    As it is primarily a CP course plz try to add lca using binary lifting 🙏🙏

  • @sakshi-ok8zu
    @sakshi-ok8zu 2 года назад +2

    i can't thank you enough for putting out such an amazing content along with the wonderful explanations 🥺💛

  • @shantanu2322
    @shantanu2322 3 года назад +1

    Mtlb katai jehar bhaiya...love you bhaiya ❤

  • @aarushiagarwal8938
    @aarushiagarwal8938 2 года назад +2

    💛💛💛💛💛💛💛 Thank you bhaiya. Your playlist helped me a lot in strengthening my concepts.
    .

  • @DjangoCourse
    @DjangoCourse Месяц назад +1

    Heart

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

    superb explanation of the observation and thereby using it as a preruiqisite for this problem.

  • @mrf92
    @mrf92 Месяц назад +1

    In the video of a algorithm topic where understanding the topic is the key. What is the necessity of using music? It causes distraction.

  • @HarshKumar-ip5nr
    @HarshKumar-ip5nr 2 года назад +2

    literally paused the video for 5 mins thinking why you added +1 instead of wt in 23rd line. lol xD, but appreciate your efforts bhaiya

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

      I still didn't get why he added +1 instead of wt as the value of wt can also be equal to 0? Can you please explain?

    • @hardkapadia5633
      @hardkapadia5633 6 месяцев назад

      At last he added wt instead of 1 it was a small mistake

  • @sadia.shafaque
    @sadia.shafaque Год назад

    Awesome explanation!

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

    Excellent explanation!

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

    very nicely explained and very nice problem.

  • @divy04
    @divy04 6 месяцев назад

    so double ended queue is just used to prevent the log n time in case of priority queue as used in dijkstra, rest of the idea is similar to dijkstra

  • @harshpaliwal6440
    @harshpaliwal6440 2 года назад +1

    Peela dil 💛

  • @nimeshsingh6229
    @nimeshsingh6229 3 года назад +1

    Luv bhai ♥

  • @jitendrakumar-vv8ho
    @jitendrakumar-vv8ho 5 месяцев назад

    What if we modify the graph and apply bfs normally ???

  • @arupabarua1721
    @arupabarua1721 Год назад +1

    i have a question. is it mandatory to add wt in the if condition in 22nd line? it doesn't make any changes. the code will still work, right?

  • @somanadhguthula147
    @somanadhguthula147 Год назад +1

    I am getting -1 in my sublime text and vs code but codeblocks and code chef i am got correct answer

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

    awesome💛💛💛💛

  • @md.hafizurrahman5436
    @md.hafizurrahman5436 2 года назад +1

    void bfs(int source)
    {
    level[source] = 0;
    queue q;
    q.push(source);
    while (!q.empty())
    {
    int ver = q.front();
    q.pop();
    for (auto child : graph[ver])
    {
    int x = child.first;
    int wt = child.second;
    if (level[ver] + wt < level[x])
    {
    level[x] = level[ver] + wt;
    q.push(x);
    }
    }
    }
    }
    Here is my accepted code. To understand why deque is needed I have tried another video and book. I have tried for making an example not passed by the only queue. I failed. Why is this code correct? What is the case when a deque is needed?

  • @apj5949
    @apj5949 3 года назад +1

    Bhaiya ji hm java basic kar chuke hai kya hm aapka ye DSA course dekh sakte hai
    Please reply 🙏🙏🙏

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

    Can we use Priority Queue to handle 0-1 part of the BFS.....?

  • @rishabhverma7730
    @rishabhverma7730 3 года назад +3

    May you can also do these topics with live stream... Save your editing and other effort and also less exhausting. (W/o doubts clearance through comment as it will make unnecessary big video )

  • @GANESHSINGH-oe2wy
    @GANESHSINGH-oe2wy 3 года назад +2

    🙏🏻 🙏🏻Sir, aap padhate waqt highlight krne ke liye konsa softwate use krte ho (jo laser jaisa dikhta hai phir apne aap gayab ho jata hai) 🙏🏻🙏🏻

    • @GANESHSINGH-oe2wy
      @GANESHSINGH-oe2wy 3 года назад

      Anyone know this??

    • @sakshitiwari7835
      @sakshitiwari7835 2 года назад +1

      @@GANESHSINGH-oe2wy not software bro,i phone ke notepad me features hai

    • @GANESHSINGH-oe2wy
      @GANESHSINGH-oe2wy 2 года назад

      @@sakshitiwari7835 😌 Ohh!! Thanks, i had never used that.. na.

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

      @@GANESHSINGH-oe2wy Goodnotes

  • @sippy8482
    @sippy8482 3 года назад +2

    Bro advance concepts bhi cover kroge kya graphs ke ?

    • @iamluv
      @iamluv  3 года назад +4

      will cover dsu might not go more ahead than that

    • @malkeetsapien4852
      @malkeetsapien4852 2 года назад +2

      @@iamluv bro Y did U stop uploading the videos now ?

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

    I wish if I had known this earlier!

  • @kaustubhgaikwad2562
    @kaustubhgaikwad2562 4 месяца назад

    can every 0-1 BFS problem be solved by Dijkstras ?

  • @shambhavamchoudhary67
    @shambhavamchoudhary67 Год назад +1

    instead of INF can we also do int INT_MAX?

    • @nishaternotes
      @nishaternotes Год назад +1

      Any number will be safe greater than N. N and N-1 also.

  • @ShaliniNegi24
    @ShaliniNegi24 2 года назад +1

    Thanks :D

  • @aledutron
    @aledutron 3 года назад +1

    ❤Thank You❤

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

    wouldn't this go into infinite steps since there is no visited states for each node ? like or 1 i will insert 2 and then for 2 i will again insert 1 and so on

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

      no babe i had the same doubt but read the code carefully no node is processed many times etc...

  • @nawabkhan4916
    @nawabkhan4916 3 года назад +1

    Yellow heart💛.

  • @unknown_coder7960
    @unknown_coder7960 3 года назад +8

    Bhaiya jab m Elon Musk ko hara dunga aur mera interview hoga to m bataunga ki maine aapki videos dekh ke cp sikha tha...

  • @funenjoynilaypatel4553
    @funenjoynilaypatel4553 2 года назад +2

    11-aug 2022

  • @AhmadMaqsood-j4v
    @AhmadMaqsood-j4v Год назад

    thanks brooo

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

    Thanx bhaiya

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

    Super

  • @divy04
    @divy04 6 месяцев назад

    please read this, it will be level[child]=level[node]+wt, i wasted an hour and rewatched the video 3 times for this

    • @AbhishekMishra-lf3yu
      @AbhishekMishra-lf3yu 6 месяцев назад

      @divy04 bro i can't understand why -1 is coming as output in program

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

    how to solve this using djikstra??

  • @commander9173
    @commander9173 25 дней назад

    yellow heart emoji nai he but ha watched till the end

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

    hello guru ji please oop also start please guru ji thanks alot

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

    itz better to apply dijkstra here using deque

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

    Bro, pls make number theory for CP

  • @Unknown-ng8me
    @Unknown-ng8me 3 года назад

    Bhai ap video ke sath notes dalthe tho hame or bhi accha lagtha padne keliye

  • @nittinrana2277
    @nittinrana2277 3 года назад +1

    👍👍

  • @vaibhavmehar
    @vaibhavmehar 3 года назад +1

    Bfs pe questions refer kro plz

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

      there questions in previous 2-3 video descriptions

  • @Girish415
    @Girish415 3 года назад +1

    ❤️

  • @AbhishekKumar-fp7bm
    @AbhishekKumar-fp7bm 2 года назад +1

    💛💛💛💛

  • @nabiladnan626
    @nabiladnan626 11 месяцев назад

    ❤❤❤

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

    yellow heart

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

    💛💛💛

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

    ❤️❤️

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

    💛

  • @epicspree6279
    @epicspree6279 3 года назад +1

    first view

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

    👍

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

    💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛

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

    💚

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

    💛💛💛💛💛💛💛💛💛

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

    💛💛💛💛💛💛💛

  • @AnujVerma-q8c
    @AnujVerma-q8c Год назад

    yeallow hart

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

    💜💚💛💙

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

    💛🌟💛

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

    🧡🧡🧡🧡🧡

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

    💞♥♥💞

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

    💛💛💛

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

    💛

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

    💛💛💛💛

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

    💛💛💛

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

    💛

  • @AbhishekMishra-rl9jx
    @AbhishekMishra-rl9jx Год назад

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

    💛💛💛

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

    💛

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

    🧡

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

    💛

  • @divyansh2212
    @divyansh2212 3 года назад +1

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

  • @nitishkumar-jh5qm
    @nitishkumar-jh5qm 2 года назад

    💛

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

    💛

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

    💛

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

    💛

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

    💛

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

    💛

  • @user-dx2sm8uh6q
    @user-dx2sm8uh6q 2 года назад

    🧡