G-5. Breadth-First Search (BFS) | C++ and Java | Traversal Technique in Graphs

  Рет қаралды 389,702

take U forward

take U forward

Жыл бұрын

GfG-Problem Link: bit.ly/3bn84K8
C++/Java/Codes and Notes Link: takeuforward.org/graph/breadt...
DP Series: • Striver's Dynamic Prog...
SDE Sheet: takeuforward.org/interviews/s...
Check out our Website for curated resources:
Our Second Channel: / @striver_79
In case you are thinking to buy courses, please check below:
Code "takeuforward" for 15% off at GFG: practice.geeksforgeeks.org/co...
Code "takeuforward" for 20% off on sys-design: get.interviewready.io?_aff=takeuforward
Crypto, I use the Wazirx app: wazirx.com/invite/xexnpc4u
Take 750 rs free Amazon Stock from me: indmoney.onelink.me/RmHC/idje...
Earn 100 rs by making a Grow Account for investing: app.groww.in/v3cO/8hu879t0
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
---------------------------------------------------------------------------------------------------------------------------

Пікірлер: 419
@takeUforward
@takeUforward Жыл бұрын
Let's continue the habit of commenting “understood” if you got the entire video. Do follow me on Instagram: striver_79
@GauravThinks
@GauravThinks Жыл бұрын
Bhaiya next bideo🥺 pls
@amarjeetkumar-hk2jl
@amarjeetkumar-hk2jl Жыл бұрын
US
@BhavyaJain-qz8jg
@BhavyaJain-qz8jg 7 ай бұрын
understood
@sanketatmaram
@sanketatmaram 6 ай бұрын
👍🏻
@SahilMadaan001
@SahilMadaan001 2 ай бұрын
understood
@UECSoumyaRay
@UECSoumyaRay Жыл бұрын
I can proudly say that this summer I watched more tUf lectures than Netflix episodes.
@aniket6858
@aniket6858 Жыл бұрын
Because your placement season is here
@Moch117
@Moch117 11 ай бұрын
@@aniket6858 What is placement? Is this india
@joseph2073
@joseph2073 11 ай бұрын
@@Moch117 no, its pakistan.
@congdatt
@congdatt 2 ай бұрын
what is the result ?
@montynathan3318
@montynathan3318 Ай бұрын
Yoh Netfilix ke hovey?😶‍🌫️
@somz21ad
@somz21ad Жыл бұрын
Hey Striver! Thank you for creating outstanding content and helping people interested in coding problems worldwide! Please don’t stress yourself out, take a break after this one. It’s not easy to work full time and dedicate time for this.
@nkgautam6161
@nkgautam6161 Жыл бұрын
you are great striver. Explain such a complex topic in very easy manner. Your method of teaching is unique, a unique lecture by a unique teacher🙏🙏🙏
@gourabbhattacharjee2128
@gourabbhattacharjee2128 Жыл бұрын
Just some simple words! No one can beat your DSA teaching style!!
@creativearts6406
@creativearts6406 3 ай бұрын
I like the way you explain time and space complexities, which actually helps me to analyze my code complexities. Thanks for the explanation.
@thealgorithm7535
@thealgorithm7535 Жыл бұрын
after seeing your post on LinkedIn that you are launching graph series 2.0 i used to see your KZbin playlist daily now I am very happy thank you very much 💗
@asadeducation9513
@asadeducation9513 4 ай бұрын
understood..awesome..most of the youtuber's don't explain a topic in depth... great video
@raghvendrakhatri5848
@raghvendrakhatri5848 Жыл бұрын
Understood each and every word♥. Kudos to your hard work and dedication, you are the motivation behind a lot of people. Your hardwork inspires a lot of people to work hard. Thankyou for providing such a beautiful graph series keep posting such content ♥, we all need this.
@cinime
@cinime Жыл бұрын
Understood! Awesome explanation as always, thank you so much!
@priyadarsinipaikaray4998
@priyadarsinipaikaray4998 11 ай бұрын
You are amazing 🤩 Guru wo hota h jo muskil si cheez ko v Asan karde tushi great ho ji striver ❤
@arthurdark3945
@arthurdark3945 Жыл бұрын
Are you going to teach leetcode questions just like you did in DP series? It would be very helpful if you can teach commonly asked good questions covering different graph patterns and not just the basic ones.
@takeUforward
@takeUforward Жыл бұрын
Yups, this one is going to be 50+ videos.
@pranavsharma7479
@pranavsharma7479 Жыл бұрын
@@takeUforward bro try to cover as max you can till 15 aug, thnks for helping
@chitrankusarkar7278
@chitrankusarkar7278 Жыл бұрын
17:04 i was still wondering where the heck vis[n] came from. edited like a pro
@nextnotification9857
@nextnotification9857 3 ай бұрын
same bro
@poetrystation3178
@poetrystation3178 2 күн бұрын
this code is not running editor is a pro for sure
@rajsekhardutta8891
@rajsekhardutta8891 Жыл бұрын
What an amazing explanation! Understood! 🤩❤‍🔥
@p38_amankuldeep75
@p38_amankuldeep75 Жыл бұрын
great content loving this after completing dp series💙💛💙
@farazjawaid2982
@farazjawaid2982 11 ай бұрын
a well explained and organised lecture !!!
@tanaysingh5348
@tanaysingh5348 Жыл бұрын
very well explained with all the minute details
@satishsingh8297
@satishsingh8297 Жыл бұрын
Thankyou striver bhaiya! ❤️
@umeshkaushik710
@umeshkaushik710 Жыл бұрын
Great work. Thanks for doing this.
@akshaikumar7966
@akshaikumar7966 Жыл бұрын
i loved it sir , what a beautiful explanation
@Maunil2k
@Maunil2k 3 ай бұрын
Nice and crystal clear explanation !!
@paullater6230
@paullater6230 2 ай бұрын
understood!! Explained beautifully!!
@kulkarnisoham
@kulkarnisoham Жыл бұрын
Awesome Space & Time Analysis 🔥🔥🔥🔥🔥🔥🔥🔥
@tharaniarumugam-zb9il
@tharaniarumugam-zb9il 16 күн бұрын
Your videos never fail to save us anytime :) Undhan rasigaiyee naaum unaken puriyavillai...
@raiusamaakram
@raiusamaakram Жыл бұрын
brilliantly explain thanks sir and neeed complete playlist of DSA from you for cracking google like companies
@anuraggoswami3534
@anuraggoswami3534 Жыл бұрын
57 +videos trurly 🇮🇳 biggest graph series Ironically GOAT 🐐 is teaching GRAPH 🤩
@Sillysmiles76
@Sillysmiles76 Жыл бұрын
Understood, Happy Learning🤗
@ramanpareek5218
@ramanpareek5218 10 күн бұрын
Liked the video, notes taken, understood
@mahaprasadm9770
@mahaprasadm9770 Жыл бұрын
brilliant explanation!
@simmi641
@simmi641 10 ай бұрын
Thank you so much stiver. Happy Teachers dayy
@rishabhagarwal8049
@rishabhagarwal8049 Жыл бұрын
Understood Sir, Thank you very much
@ayat_middya
@ayat_middya Жыл бұрын
Wonderful bhaiya.....
@RajeevCanDev
@RajeevCanDev Жыл бұрын
outstanding explanation!!
@vakhariyajay2224
@vakhariyajay2224 Жыл бұрын
Thank you very much. You are a genius.
@stith_pragya
@stith_pragya 7 ай бұрын
Thank You So Much for this wonderful video...........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@sripriyapotnuru5839
@sripriyapotnuru5839 Жыл бұрын
Thank you, Striver
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
Great video Loved it
@aditya_raj7827
@aditya_raj7827 6 ай бұрын
You are amazing striver ❣️
@aniketshukla2426
@aniketshukla2426 Жыл бұрын
What about Directed Graphs, It applies for them too? I think yes, because the adjacency list will only have those edges so we only traverse those edges
@udaypratapsingh8923
@udaypratapsingh8923 Жыл бұрын
here we go !
@shashankdesai8650
@shashankdesai8650 Жыл бұрын
Ohoo masthhh bhaiyaaaa Woohoo
@likhitbhogadi
@likhitbhogadi 3 ай бұрын
hats off to ur hard work.
@abhichi
@abhichi Жыл бұрын
Understood..next please ✌🏻
@yashpadiyar4952
@yashpadiyar4952 Жыл бұрын
Thankuu sooo muchhh broooo🤗🤗🤗❤❤❤❤❤
@ancycoding
@ancycoding 9 ай бұрын
BEST DSA TEACHER FOR ME
@vikasbagri1225
@vikasbagri1225 Жыл бұрын
understood very well...
@tanvirhasanmonir1627
@tanvirhasanmonir1627 Жыл бұрын
Thank you, understood!
@subhamoybera6456
@subhamoybera6456 Жыл бұрын
Great explanation
@alt-f4gaming222
@alt-f4gaming222 Жыл бұрын
congrats bhaiya for 300k ek din apan sath me 1m jayenge
@samuelfrank1369
@samuelfrank1369 9 ай бұрын
Understood. Thanks a lot.
@morganyu3391
@morganyu3391 Жыл бұрын
Understood bhaiya!
@supriyamanna715
@supriyamanna715 Жыл бұрын
coded on my own! Got an error, resolved the issue, all TC passed! Note taken
@futurev14
@futurev14 Жыл бұрын
Toh tujhe kya lg rha bada jhanda gaad diya tune saale itne chappal maruga
@aniketshukla2426
@aniketshukla2426 Жыл бұрын
I'm confused on the Time complexity, If we know the while loop runs N times and the size of the adjacency list is 2E, It is alright to add them to get the time complexity? like, the while loop runs N times and the for loop overall runs 2E times..??
@addictedtocricket8827
@addictedtocricket8827 Жыл бұрын
how can someone be so perfect in explianing concept
@shyren_more
@shyren_more Жыл бұрын
understood, thanks!
@nandini2783
@nandini2783 Жыл бұрын
Thankyou striver!
@kritagyaprasad7230
@kritagyaprasad7230 Жыл бұрын
Great Content
@ankitz007
@ankitz007 Жыл бұрын
Understood, Sire!
@codeman3828
@codeman3828 2 ай бұрын
Great series
@gunahawk6893
@gunahawk6893 Жыл бұрын
Woah nice explanation
@selene8721
@selene8721 17 сағат бұрын
Thank you so much!!
@paulangelp7099
@paulangelp7099 5 ай бұрын
Fantastic 🎉 Understood
@hrushi_borhade
@hrushi_borhade Жыл бұрын
understood striver!!
@kartikshukla5018
@kartikshukla5018 9 ай бұрын
Thanks sir .... best solutions
@user-mt4jk5gq7g
@user-mt4jk5gq7g 23 күн бұрын
you are the best stiver
@aasifali9139
@aasifali9139 Жыл бұрын
thx striver. Understood.
@tasneemayham974
@tasneemayham974 6 ай бұрын
bestttt!! understoodddd
@adityaroychowdhury3709
@adityaroychowdhury3709 Жыл бұрын
understood thankyou very much
@varunkumar-vs5wc
@varunkumar-vs5wc 8 ай бұрын
all clear thank u bro
@parthivsarkar6835
@parthivsarkar6835 Жыл бұрын
Understood💯
@udayrajvadeghar8555
@udayrajvadeghar8555 2 ай бұрын
UNDERSTOOD!
@_hulk748
@_hulk748 Жыл бұрын
Understood sir❤🙏🙇‍♂
@Highlights_Point
@Highlights_Point Жыл бұрын
Thanks Bhaiya
@BharatKumar-rc8vn
@BharatKumar-rc8vn 2 күн бұрын
made it simple to understand
@sagaravhad5198
@sagaravhad5198 11 ай бұрын
Thank you so much.
@radharamamohanakunnattur3035
@radharamamohanakunnattur3035 Жыл бұрын
A Big Thanks!!
@shubhigupta5689
@shubhigupta5689 Жыл бұрын
Understood🌻
@farheenkhan3248
@farheenkhan3248 11 ай бұрын
just thank you 🙏
@YeaOhYeahh
@YeaOhYeahh Жыл бұрын
If u r confused about time complexity part, then see the following dry run of the while loop of the qs. he has solved.. This is how nodes are connected(assuming undirected graph) : 0 -> 1 ,2, 3 1 -> 0 2 -> 0, 4 3 -> 0 4 -> 2 So, total no. of edges = E = 4 For first while loop , node = 0, edges = 3 Now, before going to the for loop part, u see a constant time operation O(1) --> q.pop( ) This step will be executed every time we enter into while loop. So, for first while loop how many times for loop will execute ?? It will be equal to the no. of edges , here it will be 3. Therefore, total = ( 1 + 3 ) Similarly for all other nodes, this is how it will look : ( 1 + 3 ) + ( 1 + 1 ) + ( 1 + 2 ) + ( 1 + 1 ) + ( 1 + 1 ) = 13 = O ( V + 2 * E ) = O ( 5 + 2 * 4 )
@sumerrawat6947
@sumerrawat6947 Жыл бұрын
Very well explained !
@Saurav_Kumar514
@Saurav_Kumar514 Жыл бұрын
Awesome 👌👌
@mypowerlevelisover9000
@mypowerlevelisover9000 Жыл бұрын
Thank you
@YeaOhYeahh
@YeaOhYeahh Жыл бұрын
@@mypowerlevelisover9000 🙂
@shaikhfaisal2423
@shaikhfaisal2423 Жыл бұрын
but at the worst case it will be O(n^2) right? since a complete graph have all the vertex with (n-1) edges. which will lead [(1+(n-1))=n] at each while and for loop. since after n times it will become n square. Please confirm this. BTW thanks for the explaination
@rameshbabuy9254
@rameshbabuy9254 Жыл бұрын
please also explain space and time complexities
@siddheshborse3536
@siddheshborse3536 Жыл бұрын
Understood. 😊
@LBK3
@LBK3 Жыл бұрын
Understood ❤
@ANURAGSINGH-nl2ll
@ANURAGSINGH-nl2ll 10 ай бұрын
understood thank you
@dilsedhoni9229
@dilsedhoni9229 Жыл бұрын
Understood ❤❤
@hakunamatata-nl4js
@hakunamatata-nl4js 29 күн бұрын
Thank you
@UECAshutoshKumar
@UECAshutoshKumar 11 ай бұрын
Thank you sir
@mriduljain6809
@mriduljain6809 Жыл бұрын
Understood Bhaiya
@fmkhandwala39
@fmkhandwala39 Жыл бұрын
understood!
@Shivam-fl6uv
@Shivam-fl6uv 4 ай бұрын
Understood 👍
@TON-108
@TON-108 4 ай бұрын
Understood 🥳🥳
@Shivi32590
@Shivi32590 12 күн бұрын
thank you
@KartikeyTT
@KartikeyTT 22 күн бұрын
tysm sir
@manasranjanmahapatra3729
@manasranjanmahapatra3729 Жыл бұрын
Understood!
@shreyyyc
@shreyyyc Жыл бұрын
Thanks a lot stiver for putting all these playlists out. i can't imagine getting a job if you were not on youtube. i have a little doubt that in "bfsOfGraph" function the syntax of adj[ ] should be this "Vector> adj [ ]" but it is "vector adj[ ]" instead and this is a 1D vector not a vector of vector.
@iitbhuvictim
@iitbhuvictim Жыл бұрын
Here you're creating an array of vector.... basically number of vector is fixed....that is the way to create array of vectors
@lakshsinghania
@lakshsinghania Жыл бұрын
there is a similar comment in the video number G-2 check that out
@ayushmishra9758
@ayushmishra9758 Жыл бұрын
Hence, vectoradj[n] n is no of vertices.(0 based) . adj creates an array where each adj[i] is a vector itself. Array of VECTORS.
@prachi1112
@prachi1112 Жыл бұрын
Same doubt. if we're storing an array at each index of the vector, shouldn't it be vector adj instead of vectoradj??
@ShivamTh405
@ShivamTh405 Жыл бұрын
@@prachi1112 We are storing vector in array index, i.e array of vectors. Every node of array denotes an array . Eg -> if we write int arr[] , here data type is int , so it is array of integers, but if we write vector arr[] , here data type is vector , so it is array of vector
@ankit_s
@ankit_s Жыл бұрын
Amazing
@MischievousSoul
@MischievousSoul 10 ай бұрын
There was some sound glitch for 30 sec.. Was weird but Loved the way you teach and i am here after conpleting your trees playliat... ❤
@mriduljain1981
@mriduljain1981 Жыл бұрын
understood.
@worthlessguy1621
@worthlessguy1621 3 ай бұрын
understood :)
@jagadeeshp1163
@jagadeeshp1163 6 ай бұрын
understood✅
@animalbyte453
@animalbyte453 Жыл бұрын
Understood!!
G-7. Number of Provinces | C++ | Java | Connected Components
15:29
take U forward
Рет қаралды 248 М.
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
G-10. Rotten Oranges | C++ | Java
22:30
take U forward
Рет қаралды 276 М.
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
Tarik Reacts To The VCT Champions 2024 Live Draw
12:11
Daily Dose Of Tarik
Рет қаралды 217 М.
Breadth First Search Algorithm | Shortest Path | Graph Theory
7:23
WilliamFiset
Рет қаралды 676 М.
G-11. Detect a Cycle in an Undirected Graph using BFS | C++ | Java
20:19