Bubble Sort in Plain English

Learn to implement the Bubble Sort algorithm and ace your coding interview.
👍Subscribe for more data structure and algorithm tutorials like this: goo.gl/6PYaGF
🚀Get the full data structures and algorithms course: bit.ly/2YfL3zr
CONNECT WITH ME
My Courses: codewithmosh.com
My Blog: programmingwithmosh.com
My Facebook: / programmingwithmosh
My Twitter: / moshhamedani
Data Structures and Algorithms is an essential topic taught to computer science and software engineering students to help them learn logical thinking and problem solving. That's why a lot of companies these days ask data structure and algorithm questions in their interviews. Sorting algorithms are particularly important. Even though you never have to implement a sorting algorithm in real life, studying and understanding these algorithms help you become better solving larger, more complex problems.

Пікірлер: 173

  • @utpalbarman6125
    @utpalbarman61253 жыл бұрын

    Thanks Mosh, these topics are helpful for a quick look before any job interview, data structure is very common topic in any CS related job interview, I can still remember that I was asked about Bubble Sort in an interview, and to explain the complexity. Happy to see you code in Java.

  • @vikramsapate8703

    @vikramsapate8703

    3 жыл бұрын

    @@programmingwithmosh I searched Mosh Hamedani on LinkedIn but I didn't find you.

  • @user-ze6uv7qq5d

    @user-ze6uv7qq5d

    Жыл бұрын

    Questions can come in⬆️.

  • @zeloguy
    @zeloguy3 жыл бұрын

    OMG I haven't heard of the Bubble Sort since college in '92!

  • @ashishpuma3950
    @ashishpuma39503 жыл бұрын

    Just completed your course from Udemy and I'm in love with the way of your teaching! So glad you have a KZread channel!

  • @mahmudulislam5303
    @mahmudulislam53033 жыл бұрын

    thank you Mosh. It has been a great pleasure to learn from you in youtube and udemy. You are a great teacher. You make complex things so easier, I am grateful to you.

  • @AaronAsherRandall
    @AaronAsherRandall Жыл бұрын

    I’m a C# dev and I am just shocked at how similar Java is to C#. It is literally 95% the same syntactically! I guess I know Java now 😂

  • @leoliao666
    @leoliao6662 жыл бұрын

    Thanks, Mosh! This is a fantastic video that helps me understand how it is really working! I understand the bubble sort from the book, but I never knew how to code without your video!

  • @fast5883
    @fast58833 жыл бұрын

    Best experienced instructor ever!!!

  • @Ophois47
    @Ophois473 жыл бұрын

    This was a great one Mosh, we can't thank you enough for what you do.

  • @bharat_thapa_
    @bharat_thapa_3 жыл бұрын

    Only if KZread were filled with such good content, it would be paradise for IT students. Your approach to teach is just beautiful. I need to ask this to you @Mosh: "Your opinion on PHP programming language" Thanks!

  • @angmathew4377
    @angmathew43773 жыл бұрын

    nice optimization. We also love to hear atleast one use case where it can be used practically other than in exams or interviews.

  • @Vassimau
    @Vassimau2 жыл бұрын

    I had no clue you could declare variables inside your for loop. That's awesome.

  • @talhasiddique2376
    @talhasiddique23763 жыл бұрын

    Thank you Professor Mosh Hamedani for the tutorials. If I were able to take your courses I would definitely grab the chances to do your coursrs.

  • @alestoraldous7036
    @alestoraldous70363 жыл бұрын

    mosh is one among the best instructors

  • @savage8441

    @savage8441

    3 жыл бұрын

    he is the best

  • @Jitsandcrypto

    @Jitsandcrypto

    3 жыл бұрын

    facts

  • @devendrakumargupta9021

    @devendrakumargupta9021

    3 жыл бұрын

    Bro where are you from?

  • @alestoraldous7036

    @alestoraldous7036

    3 жыл бұрын

    @@devendrakumargupta9021 Im from Kerala

  • @Aryan-ly5ho
    @Aryan-ly5ho3 жыл бұрын

    Mosh you are professional. You make a Quality base video in less earning 💰 . THANK YOU .

  • @GfoxSim
    @GfoxSim3 жыл бұрын

    The best programmer and instructor I’ve ever seen!

  • @vandithsreenivas5966
    @vandithsreenivas59663 жыл бұрын

    The sort of sort I was so confused about! Thanks Mosh!

  • @retrojimmyx
    @retrojimmyx3 жыл бұрын

    Glad you optimised at the end there. Nice vid, thanks.

  • @DiamondTech11
    @DiamondTech113 жыл бұрын

    Your are the best sir, and I got this feeling when I first saw your python course for beginners approximately 3 years ago.

  • @sagniksaha4179
    @sagniksaha41793 жыл бұрын

    I love your teaching .sir pls make a video on how to think for the soln of any given programming problem.

  • @aneeshkatkam8271
    @aneeshkatkam82713 жыл бұрын

    Mosh thank you for more courses am a fan

  • @feranmiafrica9528
    @feranmiafrica95283 жыл бұрын

    I'm currently taking your react native course.. you're just the best

  • @feranmiafrica9528

    @feranmiafrica9528

    3 жыл бұрын

    @@programmingwithmosh of course I always do

  • @KodiLearn

    @KodiLearn

    3 жыл бұрын

    @@programmingwithmosh Please create separate django course.

  • @keyasarker1559
    @keyasarker15593 жыл бұрын

    I have done your 6 hour python course and other 2 too. You are the best teacher i have ever seen in my life.Hats off to you.May you see my comment. I have a ❓ My django site was not found, when i cannot find it, when searched it through another mobile It said"error 404"

  • @khalidjabr7089
    @khalidjabr70893 жыл бұрын

    thank you for these incredible videos , you helped me in python and C sharp but i was wondering if you can do a video about data structure and algorithm in C++ hope you read this comment

  • @umarsiddique511
    @umarsiddique5113 жыл бұрын

    Mosh u r the best among all . u r the only instructor. who teaches like that. thank u.

  • @manid8302

    @manid8302

    3 жыл бұрын

    I think telusko is much better.. But also mosh is not bad

  • @jimshapedcoding
    @jimshapedcoding3 жыл бұрын

    Mosh gave me the motivation to try my own luck in being an instructor on my KZread Channel. I wish I will have his calmness and perfect explaining skills just as he does. Lots of love Mosh

  • @DeepakKumar-uz4xy
    @DeepakKumar-uz4xy3 жыл бұрын

    Thank you mosh for this awesome explanation

  • @sampurnakc
    @sampurnakc3 жыл бұрын

    If only I had full access to his courses!

  • @raphaelnk5492
    @raphaelnk54922 жыл бұрын

    Wow... That's brilliant. Using array.length - i

  • @acodingknowledge5818
    @acodingknowledge58183 жыл бұрын

    You are the best one mr.mosh, the one of people who I want to be like is you, tnx a lot from your teachs.🤗

  • @shuvramdutta8362
    @shuvramdutta83623 жыл бұрын

    Hello sir . First of all thank you very much for your tutorial courses, I learnt a lot from them and you are one of the best instructor . Sir, can make a tutorial course on machine learning or a complete stack on data science.

  • @zolisawelani9338
    @zolisawelani93382 жыл бұрын

    I really enjoyed this Mosh, thanks!

  • @highmountdigital
    @highmountdigital3 жыл бұрын

    Great video on Bubble Sort! Super instructive 👊

  • @krzysztofmazurkiewicz5270
    @krzysztofmazurkiewicz52703 жыл бұрын

    I wish my coding teacher explained it like that :) Nice one!

  • @sabitkarabayev9141
    @sabitkarabayev91413 жыл бұрын

    Very clear and understandable.

  • @xxwolf_gamezxx3358
    @xxwolf_gamezxx33583 жыл бұрын

    You are amazing, I have watched and completed all of your courses. I think you are the best programmer in the world

  • @xxwolf_gamezxx3358

    @xxwolf_gamezxx3358

    3 жыл бұрын

    I have shared all of your videos, you are my role model (for programming)!

  • @shyamsundarshrestha7590
    @shyamsundarshrestha75903 жыл бұрын

    you are the best sir

  • @infomoreandmore
    @infomoreandmore2 жыл бұрын

    I was really stuck on second iteration.....and this video saved my brain..... Thanks... :?

  • @bishalbomjan8379
    @bishalbomjan83793 жыл бұрын

    Sir you are god level in programming.

  • @sanathgowda877
    @sanathgowda8777 ай бұрын

    Awesome 🎉

  • @mikeafter5
    @mikeafter52 жыл бұрын

    Thanks very much!

  • @kashemvai5025
    @kashemvai5025 Жыл бұрын

    great explanation

  • @smrutiranjanbihari
    @smrutiranjanbihari3 жыл бұрын

    Please make a full tutorial on flutter programming. We really really waiting for that tutorial from a best tutor.

  • @aminpourhadi6188
    @aminpourhadi61883 жыл бұрын

    Hi Mosh! Thanks for the brief and clear explanation. But I would like to suggest to use JS instead of Java. because it more general + everybody can use it even in his browser and easy to understand 😉 however, you are amazing & kardorost😎

  • @gamerthinks
    @gamerthinks3 жыл бұрын

    really understandable

  • @yayahkamara5468
    @yayahkamara54683 жыл бұрын

    Thanks Mosh

  • @sujitprabhakaran9886
    @sujitprabhakaran98863 ай бұрын

    Mosh has got a million dollar Smile. Just by looking at him smile makes me very happy even in my toughest of times.

  • @user-ui3du8wo6c
    @user-ui3du8wo6c2 жыл бұрын

    Thanks a lot ! You explained it in just 11 minutes and saved me 💙💙💙💙

  • @user-ze6uv7qq5d

    @user-ze6uv7qq5d

    Жыл бұрын

    Questions can come in⬆️.

  • @yassersultan9170
    @yassersultan91703 жыл бұрын

    Thanks

  • @DarshanaHashendra
    @DarshanaHashendra3 жыл бұрын

    Brilliant video, amazing teacher so far I found for teaching programming techniques

  • @KodiLearn

    @KodiLearn

    3 жыл бұрын

    @@programmingwithmosh Please mosh create separate django course.

  • @siddarth_thiru
    @siddarth_thiru3 жыл бұрын

    Mosh when will we get Android development tutorial. Please 😭 (it's been years)

  • @averageguy985
    @averageguy9853 жыл бұрын

    Yes, we need more of the algorithms lectures

  • @averageguy985

    @averageguy985

    3 жыл бұрын

    @@programmingwithmosh already did, with my entire friends circle ☺️ thank you so much for sharing your knowledge and experience with us ☺️

  • @KodiLearn

    @KodiLearn

    3 жыл бұрын

    @@programmingwithmosh Please create separate django course. Please Mosh.

  • @demesadavenickole6580
    @demesadavenickole6580 Жыл бұрын

    Thank youuuu

  • @nishantrohilla5058
    @nishantrohilla50583 жыл бұрын

    Your are the beast teacher i am of 14 and from India I learn python with the help of you thankyou for help you are the beast instructer i make some programme with the help of you python corsethankyou very much and losts of love from India 🇮🇳🇮🇳

  • @nishantrohilla5058

    @nishantrohilla5058

    3 жыл бұрын

    Thankyou for teaching us python 😍

  • @biruk9
    @biruk92 жыл бұрын

    thank you.

  • @kavinbharathi
    @kavinbharathi3 жыл бұрын

    for people trying to do in python : ``` def bubble(arr): n = len(arr) def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i] # print('=>', arr, end=' ') for i in range(n - 1): for j in range(abs(i - n) - 1): if arr[j] > arr[j + 1]: swap(arr, j, j + 1) # print('j = ' + str(j)) return arr ``` hope it helps.

  • @silambarasan.ssethu9367
    @silambarasan.ssethu93672 жыл бұрын

    Hey Mosh , ur comment about this logic, void bubble(int[] arr) { int arrLength = arr.length; int maxSwapIndex = 0; while (arrLength > 0) { maxSwapIndex = 0; for (int i = 1; i if (arr[i - 1] > arr[i]) { swap(arr, i - 1, i); maxSwapIndex = i; } } arrLength = maxSwapIndex; } }

  • @Tanya-py3tm
    @Tanya-py3tm3 жыл бұрын

    i reallly wanted to take your course ,, but actually its alot expensive for me to enroll now😶may be I have to look for some other alternative to learn data structures and algorithm

  • @alimohmed9630
    @alimohmed96303 жыл бұрын

    you are the best instructor has ever seen 💚

  • @alimohmed9630

    @alimohmed9630

    3 жыл бұрын

    @@programmingwithmosh Your welcome 💚

  • @discreet_boson
    @discreet_boson3 жыл бұрын

    I love it when mosh uploads

  • @discreet_boson

    @discreet_boson

    3 жыл бұрын

    👍🏼

  • @armanahmed4806
    @armanahmed48063 жыл бұрын

    Sir ur tutorials are amazing plz make a one video on Django plz sir

  • @grandmastergyorogyoro532
    @grandmastergyorogyoro5323 жыл бұрын

    Time for bubble sort! Waiting!!

  • @grandmastergyorogyoro532

    @grandmastergyorogyoro532

    3 жыл бұрын

    @@programmingwithmosh I liked your explanation,it was easy to grasp, Thank.you for the wonderful explanation ✌️

  • @arifbillahsheikh9452
    @arifbillahsheikh94523 жыл бұрын

    Hi mosh this is Arif Billah from bangladesh. Youre my true mentor thank you so much

  • @munjir

    @munjir

    3 жыл бұрын

    vai cse te poren??

  • @arifbillahsheikh9452

    @arifbillahsheikh9452

    3 жыл бұрын

    I am a front end web developer now I am learning back end web development by using python Django. I would like to be a professional software engineer. Mosh is one of my best teacher.

  • @muhammadfaraz8569

    @muhammadfaraz8569

    3 жыл бұрын

    @@arifbillahsheikh9452 Salam bahi form which vadio you learn web development in Python.

  • @arifbillahsheikh9452

    @arifbillahsheikh9452

    3 жыл бұрын

    you can go to playlist of this channel you will see 6 hours python cousre .

  • @xXHelsingGamingXx
    @xXHelsingGamingXx3 жыл бұрын

    Sensei, You are awesome!! :-)

  • @rajveersamra7240
    @rajveersamra72403 жыл бұрын

    Hi, do you think your gonna make the other parts of the java course series like intermediate

  • @sahilaujla8182
    @sahilaujla81823 жыл бұрын

    Thanks for this

  • @sahilaujla8182

    @sahilaujla8182

    3 жыл бұрын

    @@programmingwithmosh sure sir

  • @freerabiul5255
    @freerabiul5255 Жыл бұрын

    you just made it more complez

  • @Bandit-is8zi
    @Bandit-is8zi Жыл бұрын

    I am proud of myself i menage to make my own sorting algoritham tonight and i didnt even knowing of bubble sort, i write it in c++ and after that asked in discord and actually find out that is my program actually bubble sort

  • @saadkhan7891
    @saadkhan78912 жыл бұрын

    Sir, I'm your student from Pakistan I love your videos so much sir the reason for my texting you is a request that can you please upload tutorial about web scraping with python i watch many videos on youtube but your method of teaching was too good i really loved it can you please do that for your students

  • @brunomauricioavilaperez824
    @brunomauricioavilaperez8243 жыл бұрын

    How do you edit your videos? please :D they are really cool

  • @AhmedKhan-rt6oz
    @AhmedKhan-rt6oz3 жыл бұрын

    Sir, please make whole series on DevOps

  • @malteeaser101
    @malteeaser1019 ай бұрын

    Funny how I've basically used the bubble sort algorithm my entire life, when mentally sorting lists, without ever knowing there was a name for it

  • @mohsin5563
    @mohsin55633 жыл бұрын

    please make a video on link list too on c++

  • @ramkumarsenthilnathan8662
    @ramkumarsenthilnathan86623 жыл бұрын

    Make more of algorithms and data structures in java . thank you

  • @ebentee

    @ebentee

    3 жыл бұрын

    You can submit question to him on the post he creat in the community tab. You just have to feel the form with your question

  • @ssp3839
    @ssp38393 жыл бұрын

    sir in the 16 th line we should give static sir public static void swap(int arr[], int index1, int index2)

  • @exoticme4760
    @exoticme4760 Жыл бұрын

    thnx

  • @mithungowdabn324
    @mithungowdabn3243 жыл бұрын

    Hi can you please make a vedio of how to use a macbook Pro, complete ( A-Z ) guide , this would help me a lot please

  • @Tanya-py3tm
    @Tanya-py3tm3 жыл бұрын

    where can i get the part 1 of this series cause am not familiar with time complexity of algorithms??

  • @mudamuda6093
    @mudamuda60933 жыл бұрын

    If we put a boolean status to determine if the array has been swapped, but the array we pass in initially has the first item smaller than the last item, than the status remains unchanged and returns.So if we pass in an array of [0,1,4,3,5] will the first 2 items be compared, seen as "arranged" and return immediately? please point out any flaws in my logic.Im referring to code at 10:13, thanks in advance.

  • @adityapatel7759
    @adityapatel77592 жыл бұрын

    Great tutorial...Can you please explain how in best case scenario we need a single pass? Because even if array is sorted we have to loop through it to know its sorted so O(n) right?

  • @user-ze6uv7qq5d

    @user-ze6uv7qq5d

    Жыл бұрын

    Questions can come in⬆️.

  • @testermailer4130
    @testermailer41303 жыл бұрын

    i have one question . how to protect passport jwt token ? example if someone get mytoken variable and copy it into other API like Postman or any other he can access fully backed user data .

  • @KodiLearn
    @KodiLearn3 жыл бұрын

    Please mosh create fully separate django course. I need that. Please mosh I really like your teaching style.

  • @KodiLearn

    @KodiLearn

    3 жыл бұрын

    @@programmingwithmosh Thank you so much for your reply. I am waiting for your course

  • @discreet_boson
    @discreet_boson3 жыл бұрын

    Can you please show a tutorial on how you make your animations

  • @eugenenovikov671
    @eugenenovikov6712 жыл бұрын

    if we have flag about swaped or not - can we get rid of two cycles and do only one cycle until flag is true?

  • @user-yd9xy3rb4x
    @user-yd9xy3rb4x2 жыл бұрын

    According to your code the scheme you showed at the beginning is wrong. Cuz index i(0) will be compared to each element in the array, then i + 1 after that comparison and so on.

  • @saidkamolanvarkhujaev1048
    @saidkamolanvarkhujaev10483 жыл бұрын

    Laravel Complete tutorial please

  • @jotaro9664
    @jotaro96643 жыл бұрын

    Saviour is back

  • @khankashani7387
    @khankashani73873 жыл бұрын

    Can you do C++ data structures and algorithms????????? Please

  • @ishtiakahmed6336
    @ishtiakahmed63363 жыл бұрын

    reminder on..

  • @muhammadfaraz8569
    @muhammadfaraz85693 жыл бұрын

    I will be coder inshallah sir if you upload advance Python and SQL.

  • @kobe-dq3uj
    @kobe-dq3uj2 жыл бұрын

    How about if it is descending mosh!

  • @abrarhasan4663
    @abrarhasan46633 жыл бұрын

    i want to take your course but i can't afford as i'm only a undergraduate student. will you help me regarding this? i will work hard.

  • @kirankulkarni04061993
    @kirankulkarni040619933 жыл бұрын

    When are you going to do a series on Cloud??

  • @hankur5883

    @hankur5883

    3 жыл бұрын

    +++++

  • @angmathew4377

    @angmathew4377

    3 жыл бұрын

    ++++

  • @arturshalimov4396

    @arturshalimov4396

    3 жыл бұрын

    You could be a bit more polite.

  • @virenparmar7366
    @virenparmar73663 жыл бұрын

    Sir Please provide django tutorial

  • @claibornebaniya9777
    @claibornebaniya97773 жыл бұрын

    Aww mero xama jopulu ho❣️❣️❣️❣️❣️

  • @KeifusMathews3
    @KeifusMathews33 жыл бұрын

    Hello I am looking to start to learn Code, where do I start and what do you recommend i start with first. I see your course on Udemy is that where I should start? Thanks

  • @KeifusMathews3

    @KeifusMathews3

    3 жыл бұрын

    @@programmingwithmosh Okay will start over the weekend, thank you and wish me luck

  • @charmainekylebongon8611
    @charmainekylebongon86112 жыл бұрын

    Hello @ Programming with Mosh can u help me about Bubble sort at Insertion sort?

  • @user-ze6uv7qq5d

    @user-ze6uv7qq5d

    Жыл бұрын

    Questions can come in⬆️.

  • @nishantrohilla5058
    @nishantrohilla50583 жыл бұрын

    Plz make more videos about phyton plz... Mosh sir.... Plzzz... Make more videos

  • @nishantrohilla5058

    @nishantrohilla5058

    3 жыл бұрын

    Mor about class and modules I need to make perfect without any error in my programms plz..... Plz..... 🙏🙏

  • @shashankpandey1019
    @shashankpandey10193 жыл бұрын

    @Mosh course price is too high $147 . Any discount or coupon available ?

  • @matthew11092

    @matthew11092

    3 жыл бұрын

    Shashank Pandey the course is available for $29 right now

  • @shashankpandey1019

    @shashankpandey1019

    3 жыл бұрын

    @@matthew11092 yuup got it, thank you

  • @siva_subramaniam
    @siva_subramaniam Жыл бұрын

    Bookmark - 09:13

  • @hasanfuad6631
    @hasanfuad66313 жыл бұрын

    Thanks as always! I wish I could see those 9 people who dislike the video.