No video

Bubble Sort Algorithm - Theory + Code

  Рет қаралды 305,100

Kunal Kushwaha

Kunal Kushwaha

Күн бұрын

This is the first video in the sorting algorithm series where we cover bubble sort in depth. We look at how the algorithm works, the complexity analysis, optimisation, and code.
Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!
👉 Resources
- Join Replit: join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: • Java + DSA + Interview...
- Code, Assignments, & Notes: github.com/kunal-kushwaha/DSA...
➡️ Connect with me: kunalkushwaha.com
=========================================
Timestamps:
0:00 Introduction
1:06 Bubble Sort
5:03 Why Bubble Sort?
8:22 Others Names of Bubble Sort
17:14 Complexity of Bubble Sort
18:04 Space Complexity
19:10 Time Complexity
21:55 Best Case
25:17 Check time complexity video for general answer
32:12 Stable and Unstable Sorting Algorithm
36:03 Code for Bubble Sort
46:06 Outro
#sorting #placement #dsa #interviews

Пікірлер: 487
@KunalKushwaha
@KunalKushwaha 10 күн бұрын
DSA + interview preparation playlist: kzfaq.info/sun/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
@StoryGicRohit
@StoryGicRohit 2 жыл бұрын
Whenever Kunal says, Why we are doing it? The answer that rings in my mind is ... We will cover it in Object-Oriented Programming. :) Great Work Kunal Love your energy
@archieavien1623
@archieavien1623 Жыл бұрын
😂😂
@ChiranjeeviGaming2003
@ChiranjeeviGaming2003 14 күн бұрын
😂😂😂😂
@Rishabhsharma-ou4dl
@Rishabhsharma-ou4dl 3 жыл бұрын
I saw many videos on KZfaq and I am currently enrolled in a paid course but no one explains bubble shot Algorithm as detailed you explained to us and for the first time I heard about Stable and Unstable Sorting Algorithm type till now I never experienced that kind of detailed explanation so thank you so much for doing such a great thing for the community. #bhaiyon_Mein_bhaiya_Kunal_bhaiya
@KunalKushwaha
@KunalKushwaha 3 жыл бұрын
Thank You!
@30sunique78
@30sunique78 Жыл бұрын
@@KunalKushwaha such a amazing Explanation
@daniel.s1621
@daniel.s1621 10 ай бұрын
True, to a 100%
@user-wf9ng6lp3b
@user-wf9ng6lp3b 3 ай бұрын
​@@KunalKushwaha hey sir what to do if there is a number more than once time, if tried it short the whole array but at the end it didn't fix number which is more than one time I use an array {2,3,5,6,8,7,9,6} and it give me result {2,3,5,6,7,8,9,6} how to fix that
@sadmansakibrabbani2181
@sadmansakibrabbani2181 2 жыл бұрын
I'm a year 2 student studying CS in Hong Kong. I'm currently enrolled in my Data Structure course and we are in Week 2 now. My uni course hasn't been amazing because professors never put enough effort into teaching. I have been following your DSA Playlist since the beginning of August. The past month has been extraordinarily amazing and I'd say I owe you one for explaining "EVERY" tiny detail of JAVA which is the primary focus of Year 2 and explaining why EVERYTHING happens, which is extremely crucial. I will absolutely rely on your playlist for this semester for my DS Course. Really appreciate this hard work. Keep it up, brother!
@jaspreetsodhi
@jaspreetsodhi Жыл бұрын
Same here in canada haha..
@princenagar1686
@princenagar1686 7 ай бұрын
Meanwhile in India these things are covered in 1st year two times, unofficially in 1st semester and officially in 2nd semester.
@dab6923
@dab6923 7 ай бұрын
​@@princenagar1686 hi fellow iiitbhian 👍
@princenagar1686
@princenagar1686 7 ай бұрын
@@dab6923 hi, what's your name??
@user-mo3mi5gr3o
@user-mo3mi5gr3o 2 ай бұрын
​@princenagar1686 which college bro ?????
@Coding-Mind
@Coding-Mind 11 ай бұрын
This is my first comment of my life, it's because of you. I really really appreciate your effort to deep dive in every topic. This is the best lecture on Bubble sort. A huge respect for you.
@lostt3435
@lostt3435 2 жыл бұрын
Very detailed video, in tears because got every bit of the video. nobody explained it this good. Keep doing the great work, Kunal.
@abhisekhkumarjha4210
@abhisekhkumarjha4210 3 жыл бұрын
BEFORE I USED TO HAVE A FEAR OF DSA TERM ONLY BUT NOW AFTER KUNAL STARTED TEACHING I FEEL IT MORE SIMPLER..THANK YOU
@Pizza_Theory
@Pizza_Theory Жыл бұрын
I was struggling with sorting, and though this is a Java DSA playlist, I gave bubble sort a shot in my CPP code. Your explanation made it feel so easy, and I managed to code it without any trouble. Thanks a ton for providing such amazing free educational content. It really helped me out! Keep up the awesome work!
@devincodes5218
@devincodes5218 Жыл бұрын
Like always Kunal, you've saved me the trouble of going through all the internet trying to grasp these concepts. Your approach to teaching makes it quite easy, thank you
@amanverma5131
@amanverma5131 2 жыл бұрын
Amazing video man! never ever algorithms seemed this interesting to me. You know how DSA is taught in unis and this is way better than that. I mean absolutely no comparison there. Keep up the good work!!
@srushtipatil9297
@srushtipatil9297 2 жыл бұрын
I did study this algorithm in college but at that time I didn't get why we were doing what we were doing and now thanks to Kunal I get it and suddenly everything makes sense, Thank you!!❤️
@siddharthsid1540
@siddharthsid1540 9 ай бұрын
why did he write swapped=false after for loop ?
@laxminarayanakoyyana1753
@laxminarayanakoyyana1753 8 ай бұрын
@@siddharthsid1540 it is just for checking if any swaps are occurring in the previous iteration , if there are no swaps ,then there is no point to go to next iteration and do this process again , instead of that we will terminate the process by checking this condition.
@Scorpio6466
@Scorpio6466 2 жыл бұрын
I had done 3 java courses and I still didn't get a lot of stuff. I thought I was quite dumb and not fit for it. But this course suddenly made a lot of things clear. I have been stuck in the same company for almost 3 years and now I think I'll be able to apply for jobs with confidence. Hats off to you for doing the unthinkable. I'll recommend everyone to go blindly for this course whether you're a noob or a pro.
@arnabdan8692
@arnabdan8692 3 жыл бұрын
I had also not scored well enough in 10th and 12th and also failed in JEE twice, I had lost all confidence untill I saw Kunal doing this great community work. I have now regained my confidence and will work hard along with your guidance and hope to do great in future. We are with you brother. #DSAwithKunal.
@rakeshpotnuru
@rakeshpotnuru 3 жыл бұрын
kunal*
@obamaengineer4806
@obamaengineer4806 2 жыл бұрын
Nahi hoga Tera
@newbieguy2509
@newbieguy2509 Жыл бұрын
@@obamaengineer4806 America ja bhai
@Kunaltwts
@Kunaltwts Жыл бұрын
​@@obamaengineer4806 tu koun hota kahne wala ki Tera nhi hoga
@AnuragSingh-yf5pv
@AnuragSingh-yf5pv Жыл бұрын
​@@Kunaltwtschutiya hai bro chor😂
@harshverma1316
@harshverma1316 3 жыл бұрын
I learnt Bubble sort 1st time in class 11 and i was like : kya h ye.... my CS teacher to me: DSA is not everyone's cup of tea ☕ so , u have to remember it for your exams(ratta laga lo ).. Also me now : Hauaa bna rakha h😒🤦‍♂️ I am in relationship with DSA now😎💕
@dakshsingh5891
@dakshsingh5891 2 жыл бұрын
Yaaa samee!!!!
@hrithikshaw434
@hrithikshaw434 3 жыл бұрын
He has such a great oratory voice that puts an icing to the cake of his teaching.. Thank you so much Kunal❤❤
@jeevikasirwani9719
@jeevikasirwani9719 2 жыл бұрын
Simple ,to the point and even the code is small.Thank you for your efforts 🙌🙌
@charlesopuoro5295
@charlesopuoro5295 Жыл бұрын
Kunal, great job as usual. Thank you for passionately charitably investing your time, energy and resources to educate us.👏👏👏
@AmitGupta-zj4gq
@AmitGupta-zj4gq 2 жыл бұрын
This man deserve the highest award for his Nobel work... Thanks a lot Kunal...
@varshneytiwari2175
@varshneytiwari2175 10 ай бұрын
for the first time i understood bubble sort,i dont thin i will ever forget it now ....thanks kunal bhaiya
@moneebk916
@moneebk916 2 жыл бұрын
This was a really great explanation! It's amazing to see the teacher work soo hard and explain each and every minute details of the algorithm
@KunalKushwaha
@KunalKushwaha 2 жыл бұрын
Glad you enjoyed it!
@unknown_515
@unknown_515 Жыл бұрын
@@KunalKushwaha Hey Kunal ! Please let us know when will you upload next video of this bootcamp.
@AnubhavMadhav
@AnubhavMadhav 2 жыл бұрын
What a quality of content and teaching as well, thank you so much Kunal!❤💯
@singhamita
@singhamita 4 ай бұрын
Free Quality Education at its best . Thank you Kunal for putting such a complex topic in very simplified manner . This channel is gonna break some records in time to come!!! God bless you with everything today and always !!!
@y.dhanush3607
@y.dhanush3607 2 жыл бұрын
Thank you bhaiya for this amazing FREE course, getting lot of confidence when you are bursting all myth's around. It's true there is no such quality content in the internet #OPKUNALBHAIYA
@pankajmalhotra8758
@pankajmalhotra8758 2 жыл бұрын
Great work and explanation! A small point: The reason explained for N^2 time complexity seems incorrect. The N^2 term seems to have a minus sign which suggests time taken would decrease with increasing N. However, if the 4 in the first term, i.e. 4N, is instead written as (N-1)*N (as N is 5 in the example taken), then N^2 will have a positive sign overall.
@pankajmalhotra8758
@pankajmalhotra8758 2 жыл бұрын
Also, for 1+2+3+4, it should be N(N-1)/2 assuming N=5.
@KunalKushwaha
@KunalKushwaha 2 жыл бұрын
Yes, you are right. It was only for this case, I didn't know how to explain before we cover complexity analysis. Hence, I'll cover complexity of each algorithm in that video.
@aniketyadav6009
@aniketyadav6009 2 жыл бұрын
Hey ! but for worst case Overall time complexity should be O(N^3) , on considering outer loop. You have considered only inner loop 31:20 as time complexity why?
@MuhammadUsman-fr4rw
@MuhammadUsman-fr4rw Жыл бұрын
@@aniketyadav6009 Same question comes into my mind i searched about it and come to know that outer loop is just iterating not taking any time (quite less which is ignorable) and most of the operations are being done in inner loop.
@Helly_Patel
@Helly_Patel 2 жыл бұрын
Thanks for teaching us like no one did till now!! One small request, please make lectures on dynamic programming as well!!
@yodude8325
@yodude8325 3 жыл бұрын
30:16 for a second I thought how can someone take so long to add 1 + 2 + 3 + 4 lmao but then I got to know you were thinking something different. Anyways kudos to your efforts towards the community!
@ervkgautam
@ervkgautam 3 жыл бұрын
That entire calculation of time complexity got completely messed up. The reason lies with the mixing up of generic N and ignoring that N= 5 for that case. Otherwise, the calculation should be straight forward: N-1 + N-2 ......+ N-(N-1) = N(N-1)/2. Also, explaining a bit about the divide-and-conquer' approach as one of the main concepts in computational thinking should have saved a lot of time in the starting that went into explaining which looks more like hitting around a bush. kudos, Kunal!
@satyamtiwari3772
@satyamtiwari3772 2 жыл бұрын
Generally I don't comment on videos ,but bro you absolutely nailed it ! Keep it up and keep it free as well .
@mohank9065
@mohank9065 Жыл бұрын
its actually midnight 3.00 am here..im going through your DSA courses here...but i never felt asleep for a single second ...you are an ammazing mentor 🤩🤩🤩🤩 ....and the way you describe it was crystal clear ....Thank you so much bro 😇😇😇
@kaiwalya_koparkar
@kaiwalya_koparkar 3 жыл бұрын
Great explanation and efforts. Thank you so much
@agyaani8060
@agyaani8060 2 жыл бұрын
Best video of bubble sort on whole KZfaq is here! Thanks kunal bhaiya❤❤✨
@madhawendrasingh1169
@madhawendrasingh1169 2 жыл бұрын
Loved the explanation and specially the optimisation that you made to the algorithm when array gets sorted. (Usually this optimisation is not given in books even). Thanks Kunal ;-)
@omarshaikh1461
@omarshaikh1461 2 жыл бұрын
Like always, another great video ! Keep going Kunal 🔥
@madara_uchiha532
@madara_uchiha532 Ай бұрын
it's really great learning with you
@poorpanda9033
@poorpanda9033 11 ай бұрын
I'm so grateful that i found your channel. Thank you so much !
@ahmadraza94_
@ahmadraza94_ 2 жыл бұрын
Great vibes and explanation. It is like something, that we always wanted, Like someone teaching you by holding your hand💖
@santhoshkumarmittapally5866
@santhoshkumarmittapally5866 Жыл бұрын
The way you explained the time complexity is great for this sorting algorithm. Your videos are very detailed. Thanks a lot for the great content. I am hearing about stable and unstable sort for the first time, thanks a lot for explaining it with colors.
@avanishdubey6556
@avanishdubey6556 2 жыл бұрын
Tomorrow I am going to explain all about bubble sort but before a day I want some confidence so that I saw the Kunal bubble sort video for the best explanation and that is amazing and after seeing this my confidence is like upper level(I am going to excite the class).
@ayushthummar3309
@ayushthummar3309 3 жыл бұрын
I have to say you have some amazing skill of teaching , Thanks kunal 👍🏻👍🏻❤️
@ishanvyas2178
@ishanvyas2178 Ай бұрын
Man thank you for the free course i will surely like all the videos and comment too. Nowhere else in youtube this type of detailed course is found
@Pradeep_00096
@Pradeep_00096 5 ай бұрын
You are beyond our expectation...Great Work brother...Thank you ...And I hope that I will master in this course within 3 months ...
@akashvenkatesh02
@akashvenkatesh02 3 жыл бұрын
Thank you for all these wonderful videos!!
@deepshah2137
@deepshah2137 2 жыл бұрын
thanks alot kunal , please complete the playlist soon
@saurabhjaswal21
@saurabhjaswal21 2 жыл бұрын
Amazing video, all doubts are cleared. Thanks man, keep doing
@Sonia-ug9wk
@Sonia-ug9wk 4 ай бұрын
Thank you for making it so easy for us.. it needs lot efforts behind at your end to deliver this quality content to us !
@sravanakirtana2787
@sravanakirtana2787 6 ай бұрын
Very Nice explanation of all topics. Especially the questions you don't only solve it but also teach how to approach and how to think on our own. This is excellent teaching. Thank you very much.
@adityamohan2820
@adityamohan2820 Жыл бұрын
an amazing course, it's great for beginners and amateur's as well, great initiative by kunal :)
@vivekr1169
@vivekr1169 Жыл бұрын
Thank you kunal for making this playlist and putting your efforts
@Mukul573
@Mukul573 3 ай бұрын
Very detailed and good explanation . Thank you for this .
@Content_creater_entertainment
@Content_creater_entertainment 20 күн бұрын
Believe me this is the best dsa playlist ever
@user-xs6dy1gw2m
@user-xs6dy1gw2m 2 ай бұрын
@Kunal Kushwaha you are fab!!
@vaibhav_kubal
@vaibhav_kubal 10 ай бұрын
Great video Kunal. Understood everything !! Thanks a lot :)
@mnchethan4208
@mnchethan4208 Жыл бұрын
Thanks Kunal for creating such a great content I understood Bubble sort in one short
@aadilnarang3468
@aadilnarang3468 2 ай бұрын
Great Work! ❣❣
@rajeshreegavhale3227
@rajeshreegavhale3227 2 ай бұрын
Best data structure playlist ,😃 Thanks kunal
@justforentertainment..2496
@justforentertainment..2496 4 ай бұрын
Thank you kunal for this amazing video it will understand for even 5th grade student also great job!
@taha2559
@taha2559 Жыл бұрын
The best one on youtube! Big love kunal❤‍🔥
@akhila5597
@akhila5597 3 жыл бұрын
Amazing detailed explanation!
@pradeepraok4435
@pradeepraok4435 2 жыл бұрын
Im 2nd Year CSE btech but didnt knew about stable and unstable sorting algorithm before this video.Thanks for the info.
@jamesheller2707
@jamesheller2707 2 жыл бұрын
Understood everything, Best bubble sort video ever
@amaanullah13
@amaanullah13 Жыл бұрын
Yayyy, I always learn something new from you 🤗. You are a true gem 💎 Please complete the rest of the topics🥺too. Ab final year mein aagye hai And my tension is 📈
@nagarjunaakkisetty6801
@nagarjunaakkisetty6801 Жыл бұрын
Great working Kunal sir and explaining very well .
@surajmaity6194
@surajmaity6194 2 жыл бұрын
I learnt new concept over sorted array and also time complexity part. Amazing
@implementtech9683
@implementtech9683 Ай бұрын
Love your way of teaching...
@user-nh9hb9yl7v
@user-nh9hb9yl7v 6 ай бұрын
amazing video. Way of teaching is gr8
@Poetichealing8
@Poetichealing8 7 ай бұрын
Very Nice Explanation Kunal
@piyushkhandelwal1662
@piyushkhandelwal1662 2 жыл бұрын
Video is awesome i completed this video in just one shot thank you so much sir 🤗🤗🤗
@ananttiwary8552
@ananttiwary8552 Ай бұрын
thank you sir for making this free resource
@amanrawat5271
@amanrawat5271 3 ай бұрын
One of the most knowledgeable and topics are so deeply explained !! in this video ..
@shashianand6919
@shashianand6919 Жыл бұрын
👌👌👌Tremendous effort and explanation kunal✊✊✊🎉🎉
@prasun_harsh
@prasun_harsh 6 ай бұрын
Hey Kunal you are doing fantabulous job bro. I had completed my undergrad last year and I started dsa from last month for career advancement .Literally speaking the way you explain thing in simple way is awesome.
@tungnguyen26789
@tungnguyen26789 7 ай бұрын
My professor went over all type of sorts in like half an hour, I got basically zero knowledge from that lecture. Thank you Kunal for giving effort to create such a detailed lecture on bubble sort.
@nilabhjoshi7556
@nilabhjoshi7556 10 ай бұрын
following the course with patience its awesome
@aastharawat321
@aastharawat321 Жыл бұрын
You explained each and every concept in very detailed manner🤞🤞
@asher4312
@asher4312 Жыл бұрын
Great video BRO!!
@rohit4663
@rohit4663 10 ай бұрын
Bubble sorting well explained in depth. Thanks Kunal ❤
@girirajtomar519
@girirajtomar519 2 жыл бұрын
Thank for such a great video kunal.
@RaviShankar-xn1sv
@RaviShankar-xn1sv 3 жыл бұрын
Kunal Thanks alot for all your hardwork! It's really helpful : ) Thanks
@ishukhare1314
@ishukhare1314 2 жыл бұрын
Understood completely. Not even a single doubt.
@Pradeep_00096
@Pradeep_00096 5 ай бұрын
Though i know bubble sort I played a video and hence you proved that you will introduce new things in it..Great work brother
@SriHarsha02
@SriHarsha02 2 жыл бұрын
Thank you Kunal for clear explanation.
@kunalgarg1219
@kunalgarg1219 2 жыл бұрын
Amazing explanation Kunal. Thanks a lot :-)
@vaibhavimishra763
@vaibhavimishra763 10 ай бұрын
Your explanation really makes the things so so clearer , thanku for teaching us so nicely ☺️👌
@glaide1500
@glaide1500 Ай бұрын
Very clean and neat.
@googlemani
@googlemani 2 жыл бұрын
Best explanation on bubble sort. Thank you Kunal for the awesome work 👏👌
@KunalKushwaha
@KunalKushwaha 2 жыл бұрын
Glad you liked it
@googlemani
@googlemani 2 жыл бұрын
​@@KunalKushwaha Your DSA playlist is excellent content I have found on the subject till date. I have not completed the entire playlist, but I can confidently say with the lectures so far I watched. Thanks again.
@praveshverma0808
@praveshverma0808 10 ай бұрын
Noone can defeat you in teaching and explanation ways 😘
@swarnavadhar5812
@swarnavadhar5812 5 ай бұрын
Currently I am in the final year of my MCA and I found this playlist, if I would have found this earlier, my concept would have been lot more clearer, but I still decided to watch it, and with each and every video I am getting more and more excited, and learning a lot more thing with clarity. #dsa_god_kunal_kushwaha
@rahuldwivedi9236
@rahuldwivedi9236 3 жыл бұрын
first time seeing someone talking about stability of sorting algo nice
@anjalithakur_12
@anjalithakur_12 2 жыл бұрын
This was good and a very great explaination. Thanks for the efforts
@manishdhakeria4518
@manishdhakeria4518 Жыл бұрын
Thanks Kunal, it is really great, i tried by reducing the first loop after every run because last element is anyway the largest in array. // Here y is my array for(int count=y.length;count >0; count--){ for (int i=0;iy[i+1]) { int temp = y[i]; y[i] = y[i+1]; y[i+1] = temp; } } }
@akash-
@akash- 3 жыл бұрын
hope we'll also see more n more question on sorting! sach mein bahiya BS mein mja aagya tha :)
@udaysingh2484
@udaysingh2484 Жыл бұрын
Grasped most of it. Thank you Kunal ❤
@MuhammadArslan-px1sm
@MuhammadArslan-px1sm 2 ай бұрын
very detailed and comprehensive
@sumit8806p
@sumit8806p 2 жыл бұрын
As always, great explanation.
@chukwumaprince6539
@chukwumaprince6539 10 ай бұрын
Awesome lecture. Well-done boss
@atharvatatpuje2766
@atharvatatpuje2766 Жыл бұрын
Great Content 🧑🏻‍💻
@kmohammedalthaf3535
@kmohammedalthaf3535 2 жыл бұрын
@Kunal Kushwaha it's a really great video, I came here to check how good you will explain, but it made me stay till the end of the video, I really appreciate your work, keep growing, our support will be always there.
@KunalKushwaha
@KunalKushwaha 2 жыл бұрын
Thank You!
@kaustubhyashukla2237
@kaustubhyashukla2237 2 жыл бұрын
Great video and detailed and apt explaination
@308varaprasad4
@308varaprasad4 2 жыл бұрын
Thanks for Bringing this Lecture Series
@smilemania5102
@smilemania5102 3 жыл бұрын
Great work 👏👏👏 I am your fan ❤️
@aryanparishwad24
@aryanparishwad24 7 ай бұрын
Beautifully explained!
Selection Sort Algorithm - Theory + Code
18:49
Kunal Kushwaha
Рет қаралды 223 М.
Binary Search in 2D Arrays
58:57
Kunal Kushwaha
Рет қаралды 290 М.
Lehanga 🤣 #comedy #funny
00:31
Micky Makeover
Рет қаралды 23 МЛН
Они так быстро убрались!
01:00
Аришнев
Рет қаралды 2,4 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 94 МЛН
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 411 М.
Strings and StringBuilder in Java
1:27:29
Kunal Kushwaha
Рет қаралды 431 М.
5 Math Skills Every Programmer Needs
9:08
Sahil & Sarra
Рет қаралды 1 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 869 М.
Insertion Sort Algorithm - Theory + Code
30:40
Kunal Kushwaha
Рет қаралды 218 М.
Solve Any Pattern Question With This Trick!
57:20
Kunal Kushwaha
Рет қаралды 2,3 МЛН
Cycle Sort - Amazon, Google, Microsoft Interview Questions
1:35:32
Kunal Kushwaha
Рет қаралды 360 М.
Lehanga 🤣 #comedy #funny
00:31
Micky Makeover
Рет қаралды 23 МЛН