Bubble Sort Algorithm - Theory + Code

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

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

  • @KunalKushwaha
    @KunalKushwaha  4 месяца назад +9

    DSA + interview preparation playlist: ruclips.net/p/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ

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

      Dart & Flutter course please

  • @StoryGicRohit
    @StoryGicRohit 3 года назад +203

    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

  • @sadmansakibrabbani2181
    @sadmansakibrabbani2181 3 года назад +142

    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 Год назад +2

      Same here in canada haha..

    • @princenagar1686
      @princenagar1686 11 месяцев назад +2

      Meanwhile in India these things are covered in 1st year two times, unofficially in 1st semester and officially in 2nd semester.

    • @dab6923
      @dab6923 10 месяцев назад +2

      ​@@princenagar1686 hi fellow iiitbhian 👍

    • @princenagar1686
      @princenagar1686 10 месяцев назад +1

      @@dab6923 hi, what's your name??

    • @Nameiscantsay
      @Nameiscantsay 6 месяцев назад +1

      ​@princenagar1686 which college bro ?????

  • @Rishabhsharma-ou4dl
    @Rishabhsharma-ou4dl 3 года назад +278

    I saw many videos on RUclips 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 года назад +41

      Thank You!

    • @30sunique78
      @30sunique78 Год назад +3

      @@KunalKushwaha such a amazing Explanation

    • @daniel.s1621
      @daniel.s1621 Год назад +1

      True, to a 100%

    • @PanditAyushparashari
      @PanditAyushparashari 7 месяцев назад

      ​@@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

  • @Coding-Mind
    @Coding-Mind Год назад +7

    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.

  • @Content_creater_entertainment
    @Content_creater_entertainment 4 месяца назад +3

    Believe me this is the best dsa playlist ever

  • @Scorpio6466
    @Scorpio6466 2 года назад +8

    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.

  • @AmitGupta-zj4gq
    @AmitGupta-zj4gq 2 года назад +3

    This man deserve the highest award for his Nobel work...
    Thanks a lot Kunal...

  • @srushtipatil9297
    @srushtipatil9297 3 года назад +21

    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 Год назад

      why did he write swapped=false after for loop ?

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

      @@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.

  • @arnabdan8692
    @arnabdan8692 3 года назад +54

    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.

  • @mohank9065
    @mohank9065 Год назад +5

    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 😇😇😇

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

    BEFORE I USED TO HAVE A FEAR OF DSA TERM ONLY BUT NOW AFTER KUNAL STARTED TEACHING I FEEL IT MORE SIMPLER..THANK YOU

  • @harshverma1316
    @harshverma1316 3 года назад +16

    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😎💕

  • @hrithikshaw434
    @hrithikshaw434 3 года назад +17

    He has such a great oratory voice that puts an icing to the cake of his teaching.. Thank you so much Kunal❤❤

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

    completed and going ahead with full excitement.

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

    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.

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

    Very detailed video, in tears because got every bit of the video. nobody explained it this good. Keep doing the great work, Kunal.

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

    for the first time i understood bubble sort,i dont thin i will ever forget it now ....thanks kunal bhaiya

  • @singhamita
    @singhamita 8 месяцев назад +1

    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 !!!

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

    The way Kunal bhaiya is explaining things is top-notch. Thankyou for this free DSA course ❤

  • @yodude8325
    @yodude8325 3 года назад +14

    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 года назад +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!

  • @prasun_harsh
    @prasun_harsh 10 месяцев назад

    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.

  • @pankajmalhotra8758
    @pankajmalhotra8758 3 года назад +23

    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 3 года назад +3

      Also, for 1+2+3+4, it should be N(N-1)/2 assuming N=5.

    • @KunalKushwaha
      @KunalKushwaha  3 года назад +17

      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.

  • @amanverma5131
    @amanverma5131 2 года назад +6

    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!!

  • @moneebk916
    @moneebk916 2 года назад +26

    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 года назад +13

      Glad you enjoyed it!

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

      @@KunalKushwaha Hey Kunal ! Please let us know when will you upload next video of this bootcamp.

  • @RaviShankar-xn1sv
    @RaviShankar-xn1sv 3 года назад

    A friendly reminder 🙃
    Please like this video...it might reach to a student who needs this because of your like.
    So do the good work people.thanks

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

    Generally I don't comment on videos ,but bro you absolutely nailed it !
    Keep it up and keep it free as well .

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

    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;
    }
    }
    }

  • @Dhanush.Y
    @Dhanush.Y 3 года назад +9

    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

  • @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!

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

    Already know this sorting but new thing i learnt is Stop When It is not Swapping for Particular Value of i.
    Nice video🎉🎉

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

    Trust me guys its best course among all the paid DSA courses tqs kunal❤

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

    Hey Kunal!
    It was an awesome lecture.
    Just to clarify, I is running 5 time if you see it in your code. But according to theory it should run actually 5-1= 4 times. We are starting from zero. So actually it should be, i < arr.length -1; So loop is running one extra time.
    Break is there to help it out obviously. But just for clarification if anyone has any doubt

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

      Yep, the reason is that sometimes for code clarity such optimisations can be ignored. Also I mentioned we will discuss complexity in detail in time complexity lecture.

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

      I also noticed it and wanted to check if any of the others did find it ..

  • @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

  • @ishanvyas2178
    @ishanvyas2178 5 месяцев назад

    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

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

    Noone can defeat you in teaching and explanation ways 😘

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

    Simple ,to the point and even the code is small.Thank you for your efforts 🙌🙌

  • @avanishdubey6556
    @avanishdubey6556 3 года назад +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).

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

    What a quality of content and teaching as well, thank you so much Kunal!❤💯

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

    Thank you for all the amazing lectures.
    #bhaiyon_Mein_bhaiya_Kunal_bhaiya

  • @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.

  • @shahsikalagowda183
    @shahsikalagowda183 Месяц назад

    Day by day i am falling in love with ur course❤

  • @Pradeep_00096
    @Pradeep_00096 8 месяцев назад

    You are beyond our expectation...Great Work brother...Thank you ...And I hope that I will master in this course within 3 months ...

  • @AyushiSingh-q8m
    @AyushiSingh-q8m 6 месяцев назад +1

    @Kunal Kushwaha you are fab!!

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

    Best video of bubble sort on whole RUclips is here! Thanks kunal bhaiya❤❤✨

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

    Kunal, great job as usual. Thank you for passionately charitably investing your time, energy and resources to educate us.👏👏👏

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

    Understood completely. Not even a single doubt.

  • @googlemani
    @googlemani 2 года назад +6

    Best explanation on bubble sort. Thank you Kunal for the awesome work 👏👌

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

      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.

  • @KshitizAnand-xr1wj
    @KshitizAnand-xr1wj 3 месяца назад

    Thank you Kunal for sharing such an optimised code for bubble sort.

  • @sravanakirtana2787
    @sravanakirtana2787 9 месяцев назад

    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.

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

    Im 2nd Year CSE btech but didnt knew about stable and unstable sorting algorithm before this video.Thanks for the info.

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

    Thanks for teaching us like no one did till now!! One small request, please make lectures on dynamic programming as well!!

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

    Great explanation and efforts. Thank you so much

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

    The only video that fixes code for O(N) - Best Case complexity 🤯🙌🙌

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

    thanks alot kunal , please complete the playlist soon

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

    following the course with patience
    its awesome

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

    I saw some channels having heart attack at LinkedIn 😁
    Kunal bhai you are rocking can't wait to start Ml and Web-D after DSA.
    Lots of loves to you😍

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

    Its by far very well structured course ever

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

    oo bhai sahab ya to next level pa concept da rha ho bhiya aap to maza aa gya

  • @Pradeep_00096
    @Pradeep_00096 8 месяцев назад

    Though i know bubble sort I played a video and hence you proved that you will introduce new things in it..Great work brother

  • @madara_uchiha532
    @madara_uchiha532 4 месяца назад +1

    it's really great learning with you

  • @amanrawat5271
    @amanrawat5271 7 месяцев назад

    One of the most knowledgeable and topics are so deeply explained !! in this video ..

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

    Bubble sorting well explained in depth. Thanks Kunal ❤

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

    My favorite teacher😌😌😌kunal sir..!!!

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

    Best DSA video i have ever seen...Great teaching skilll....

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

    You explained each and every concept in very detailed manner🤞🤞

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

    36:48 it will be i < arr.length-1 actually, as we want to have (n-1) pass so [0,n-2] are n-1 passes/or value of i.

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

    I just solved a medium-level question which was "binary search in 2D array" after watching this video.

  • @tloumoreti4800
    @tloumoreti4800 4 месяца назад +1

    What a legend❤❤

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

    hey Kunal !!!, first of all thank you so much for this playlist, I have doubt in the outer for loop isn't it "i

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

    I'm so grateful that i found your channel. Thank you so much !

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

    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 📈

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

    I'm tired of thanking you again and again.
    Thank you!😅

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

      Is this course good for beginner?

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

    Thank you kunal for making this playlist and putting your efforts

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

    Thank you Kunal for clear explanation.

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

    Legendary explainations!! Thanks alot for efforts on this video!!! @KunalKushwaha

  • @Happiness_sonia
    @Happiness_sonia 7 месяцев назад

    Thank you for making it so easy for us.. it needs lot efforts behind at your end to deliver this quality content to us !

  • @t.c.a.n.scyberz9959
    @t.c.a.n.scyberz9959 2 месяца назад +2

    I love his content

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

    Great vibes and explanation.
    It is like something, that we always wanted,
    Like someone teaching you by holding your hand💖

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

    when you talked about the boolean check, I was like amazed because every other person teaching bubble sort never talks about that. seriously that just 2-3 lines of code will have a big impact on time complexity when n is very big and array gets sorted before n^2 comparisions.

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

    I learnt new concept over sorted array and also time complexity part.
    Amazing

  • @DURGASREECHOWDHARYKOMMINI
    @DURGASREECHOWDHARYKOMMINI 15 дней назад

    I am so excited to learn further and more interested, great and clear explanation ❤

  • @invisible2054
    @invisible2054 Месяц назад

    Extremely mind blowing video ❤

  • @Sanjay-Jangid
    @Sanjay-Jangid Год назад

    Thankyou Kunal for such amazing DSA course. 🙏🙏
    #DSAwithKunal

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

    The best one on youtube!
    Big love kunal❤‍🔥

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

    No doubt by the time of completion of this series likes will be 100k+ and subscription 10M🥰🥰 thanks kunal for such selfless effort ...

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

    thank you sir for making this free resource

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

    Grasped most of it. Thank you Kunal ❤

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

    Best data structure playlist ,😃 Thanks kunal

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

    Amazing video, all doubts are cleared. Thanks man, keep doing

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

    Thanks Kunal for creating such a great content
    I understood Bubble sort in one short

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

    Thanks for explaining this swapped Boolean condition. Awesome.

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

    You are a role model for me.

  • @aniketmore1410
    @aniketmore1410 7 месяцев назад

    Before watching this video, I didn't know their something like stable or unstable sorting for bubble sort. Thanks kunal for such deep explanation. 😊❤

  • @swarnavadhar5812
    @swarnavadhar5812 8 месяцев назад

    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

  • @D.S.Apkare
    @D.S.Apkare 2 года назад +1

    Hi kunal sir
    Sorry for distributing
    But I want to appreciate your work
    Your explanation is very cristal clear for me
    Even your handwritten notes is very useful. That helped me very well
    As you told they is no course like this.i felted that too.
    Thank you very much

  • @Mukul573
    @Mukul573 7 месяцев назад

    Very detailed and good explanation . Thank you for this .

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

    Your explanation really makes the things so so clearer , thanku for teaching us so nicely ☺️👌

  • @308varaprasad4
    @308varaprasad4 2 года назад

    Thanks for Bringing this Lecture Series

  • @implementtech9683
    @implementtech9683 5 месяцев назад

    Love your way of teaching...