Sorting - Part 1 | Selection Sort, Bubble Sort, Insertion Sort | Strivers A2Z DSA Course

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 1,3 тис.

  • @takeUforward
    @takeUforward  Рік тому +62

    Book a FREE career counseling session with Learnbay: bit.ly/3km2s6W
    Let's march ahead, and create an unmatchable DSA course! ❤
    Can someone please add timestamps, I will add them post-it.

    • @sweetyjain8204
      @sweetyjain8204 Рік тому

      Hey @striver @take U forward
      , it's a humble request can u, please complete this series soon as the placement season is coming soon....🙏

    • @Vikash-zq7vx
      @Vikash-zq7vx Рік тому

      Hey Striver please complete the series.

    • @mgfreefirelover4471
      @mgfreefirelover4471 Рік тому

      @takeUforward Hey!
      Can you complete Binary search Section more quickly

    • @aniltandivitb4482
      @aniltandivitb4482 Рік тому

      Bhaiya , if we solve a question and if need to sort the array then which algo we would to implement

    • @webtestingui7187
      @webtestingui7187 Рік тому +3

      Kaha thay aap,maine itna YT me search kia but aapka channel suggest nahi huwa until mera ek dost ne nahi bola hota
      Maira DSA teacher ne jo topic clear nahi karwa pa a aap wo kar di a
      Thank you

  • @saurabh8260
    @saurabh8260 Рік тому +442

    A lot of problems are going on in my life right now. But still I'm showing up everyday to learn something new in dsa and to solve questions.
    Problems will come and problems will go but I should continue my hustle.
    All of our struggles will pay off one day.

    • @dhruvrajsinhgohil6715
      @dhruvrajsinhgohil6715 Рік тому +33

      Hope is the most precious thing do not lost it

    • @darshanakv4946
      @darshanakv4946 8 місяців тому +6

      Beautiful message that I saw today!

    • @pulkit-rastogi97
      @pulkit-rastogi97 8 місяців тому +2

      This motivate me, I am going through some similar situation

    • @SauravSingh-xm6nn
      @SauravSingh-xm6nn 7 місяців тому +5

      @@pulkit-rastogi97
      don't lose your hope , just keep giving your best so that you won't regret, in fact if you honestly give your best you can , you are likely to succeed !

    • @vaibhavagarwal602
      @vaibhavagarwal602 7 місяців тому +5

      Same man, i was struggling to get up from bed the entire day. But finally at 11pm i decided i will atlest spend the last hout of my day working towards my financial independece

  • @chhavigoel7030
    @chhavigoel7030 Рік тому +58

    So many videos on Sorting on the internet yet this proves to be the BEST. Thank you so much.

  • @msdarshankirthic
    @msdarshankirthic Рік тому +175

    Selection Sort TC -> worst - O(N^2) best - O(N^2)
    2:45 - Selection Sort
    6:50 - pseudo code / implementation for selection sort
    14:28 - C++ code for selection sort
    Bubble Sort TC -> worst - O(N^2) best - O(N)
    17:41 - Bubble Sort
    22:00 - pseudo code / implementation for bubble sort
    25:52 - C++ code for bubble sort
    Insertion Sort TC -> worst - O(N^2) best - O(N)
    31:40 - Insertion Sort
    36:55 - pseudo code / implementation for insertion sort
    38:52 - C++ code for insertion sort

    • @afzalmd23
      @afzalmd23 Рік тому +7

      Thinking about your notes📝 😮😮

  • @ravenin9612
    @ravenin9612 3 місяці тому +26

    I first watched this video and i understood this partially, its fascinating how a few lines of code can be so confusing. Maybe thats why dsa is still considered to be very hard. I finally understood this concept after writing the code in paper and analyzing each iteration and what happens after the same. If anyone dont understand the topic, just do the same and you will understand it.

  • @shubhamagarwal1434
    @shubhamagarwal1434 5 місяців тому +6

    #Free Education For All...... # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India.........

  • @hypernova5159
    @hypernova5159 Рік тому +30

    The amount of effort you put in these videos is truly amazing. Thanks a lot 🙏

  • @acroshubham
    @acroshubham 9 місяців тому +4

    Stirver-Forever, Just striving to become the best version of myself. All thanks to raj vikrmaditya bhaiya. You're the best hope for students like us, belonged from tier-3 college, where there is no hope in hell to get a sde job, but their is this man standing with a freakin Sun the light the path for use. I don't know how I will thank you but one day I believe all my hard work will pay off when I will meet you and telling you my story of life, how I made zero to Prodigy. Till I didn't hit it, byy sir I am going back to hustle....

  • @nandhakrishna2330
    @nandhakrishna2330 Рік тому +18

    The amount of effort you put in these videos is truly amazing. 🙏

  • @aydasu
    @aydasu Рік тому +15

    Striver, you are a gift to us all! thanks so much!

  • @Sreelekha-z9
    @Sreelekha-z9 20 днів тому

    there is no YT channel that teaches DSA Better than you. Thank you sooooo muchhhh. Even a beginner can understand very easily

  • @raimasoni3013
    @raimasoni3013 Рік тому +157

    2:45 Selection Sort
    17:41 Bubble Sort
    31:40 Insertion Sort
    😊

  • @charlesbabbage6786
    @charlesbabbage6786 10 місяців тому +8

    What an AMAZING teacher!!!

  • @amareshghosh3502
    @amareshghosh3502 Рік тому +3

    khub sundar, osadharon🙂

  • @zubairmirza-j3h
    @zubairmirza-j3h 4 місяці тому +1

    BEST DSA TEACHER I HAVE EVER SEEN YOU ARE JUST AMAZING !!!

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 Рік тому +22

    😅😅As usual awesome!!

  • @bhuvangowda4842
    @bhuvangowda4842 4 місяці тому +1

    You make many people's life easier by teaching and making everyone understand so easily

  • @omgaikwad5962
    @omgaikwad5962 Рік тому +8

    HI Striver,
    One request please provide the videos for upcoming topics asap and Big thank for providing such an amazing series.

  • @JazzSparrow0321
    @JazzSparrow0321 10 місяців тому +1

    I find this is best DSA video i have ever seen on youtube. Thabak you Mr. TUF for this informative session.

  • @sumitvishwkarma6907
    @sumitvishwkarma6907 Рік тому +5

    This is going to be one of the best series of all time, thankyou so much raj bhaiya, just a small request can you please upload new videos asap, btw thankyou again ❤

  • @rishikeshg8926
    @rishikeshg8926 Рік тому +2

    Understood
    Thanks for this video bhai!

  • @Manishgupta200
    @Manishgupta200 Рік тому +6

    Thankyou Striver. It's really an easy to understand. I also learnt to find Time Complaxity from every code by myself after seeing this video. Please make video on other sorting methods. ❤

  • @surajgoraicse
    @surajgoraicse Рік тому +1

    Finally I found the best DSA course on UA-cam. ❤The way you explain concept is awesome. ❤❤
    There was not a single second when I felt bored . Thankyou very much for your effort. ❤❤
    ❤❤

  • @milindjarsaniya
    @milindjarsaniya Рік тому +3

    PERFECTLY UNDERSTOOD! ❤

  • @cinime
    @cinime Рік тому +5

    Understood! Amazing explanation as always, thank you very much for your continuous effort for making the video!!

    • @universal-1903
      @universal-1903 6 місяців тому

      bro in insertion ,why does i has starting value of 0 ,shouldnt it be 1 as single element would be sorted anyways

  • @BoraSaiVenkataPraveenKumar
    @BoraSaiVenkataPraveenKumar Місяць тому

    understood.
    very nice explanation that made me write the code even before you completed writing the code just by listening to the logic you taught

  • @28_g_pawanvinayakawasthi23
    @28_g_pawanvinayakawasthi23 Рік тому +20

    Hi Striver @takeUforward , in the insertion sort ,the outer loop i.e. the loop with i should start with i=1 instead of i=0 because the j takes the value of i and in the while loop it says j should be greater than 0 so it will always stand false for the first iteration ( j=i=0) and moreover we don't need to check the correct order of single element . Please correct me if i am wrong because i am just saying what I understood .

    • @ShubhraneelChakraborty-cj8zm
      @ShubhraneelChakraborty-cj8zm 11 місяців тому +4

      Yeah you are right I believe. When I saw the outer loop, I was thinking the same thing and when I run the code, it prints the same output as with i=0, just as I thought it would be during the dry run.

  • @reddotcheese
    @reddotcheese 11 місяців тому +1

    It's easiest explanation I have seen. Appreciate the effort that went.

  • @animexworld6614
    @animexworld6614 Рік тому +114

    Hey striver , it's a humble request can u, please complete this series soon as the placement season is coming soon....🙏

    • @bishalkundu7592
      @bishalkundu7592 Рік тому +8

      Yes striver 😭 plzzz Want to learn the whole series just from u. Already watched DP and Graph and Trees playlist from ur channel. Plzz striver try to complete this series as soon as possible 😭

    • @harshavardhan184
      @harshavardhan184 Рік тому +1

      Yes please 🥺🥺🥺

    • @venomhighs1937
      @venomhighs1937 Рік тому +5

      brother once striver reaches to Poland he will be regular in posting videos !!

    • @yikes3807
      @yikes3807 Рік тому +6

      @@bishalkundu7592 u completed DP graph trees and you are waiting for basic topics?

    • @bishalkundu7592
      @bishalkundu7592 Рік тому

      @@yikes3807 Not basic but ya heaps Sliding windows stacks Queues Binary Search. Waiting for this

  • @sarthaksharma9322
    @sarthaksharma9322 6 місяців тому +1

    Understood! Thanks Striver for all this knowledge you are providing for free!

  • @Raj10185
    @Raj10185 Рік тому +9

    one suggession for insertion sort
    why we run outerloop from i = 0 we should start directly from i = 1 till iarr[j])
    {
    int temp = arr[j];
    arr[j]=arr[j-1];
    arr[j-1]=temp;
    j--;

    }

    • @AryanRishi-vk6et
      @AryanRishi-vk6et 7 місяців тому +2

      it wouldn't impact anything if the outer loop is running from 0 to n-1 then when i = j = 0 it will no go into the while loop and move on to next iteration of i

    • @dhruvverma1001
      @dhruvverma1001 6 місяців тому

      I want to understand how does is not give index out of bound error by accessing -1, or it does short curcuit

    • @coder-2026
      @coder-2026 3 місяці тому

      @@dhruvverma1001 j>0, it will start forom j=1. for j=1 , the comparison will be between arr[0] and arr[1]

  • @ArvindSingh-wj7vy
    @ArvindSingh-wj7vy 11 місяців тому +1

    Absolutely understood Stiver!💌

  • @yashvardhansingh5341
    @yashvardhansingh5341 8 місяців тому +8

    For bubble sort striver you are using i>=1 in outer loop in the pseudo code but while using the code editor you are using i>=0.

    • @ankitpal8044
      @ankitpal8044 6 місяців тому

      Same doubt??

    • @nirbhaybhardwaj4330
      @nirbhaybhardwaj4330 6 місяців тому

      there is no need of going till i>=0 . but if you go , this is also right .....i=0 is automatically got minimum number when we are sorting

    • @WebhubPlays
      @WebhubPlays 2 дні тому

      Editor one is correct

  • @itsmehere8285
    @itsmehere8285 2 місяці тому

    Omggg!! This is soooo good!! Really hope I get DSA finally with following your videos

  • @shivamsingh-we7ek
    @shivamsingh-we7ek Рік тому +12

    please complete this series soon because only 3,4 months are left for placement season its a humble request

    • @Mebutdifferent
      @Mebutdifferent 2 місяці тому

      how it went your placements?

    • @shivamsingh-we7ek
      @shivamsingh-we7ek 2 місяці тому

      @@Mebutdifferent got decent offer

    • @RISWANAHAMED.M
      @RISWANAHAMED.M 2 місяці тому

      can u share anything about your intrew prepariation as i have my placements within 6 months ? if i follow striver is it enough for dsa ?

    • @dhruvdonsahu9972
      @dhruvdonsahu9972 2 місяці тому

      @@shivamsingh-we7ek congratulations

  • @curs3m4rk
    @curs3m4rk 10 місяців тому

    This is a very good explanation.
    With help of explanation itself I'm able to code and did the sorting.
    Really appreciate the efforts.

  • @swarupsaha9064
    @swarupsaha9064 Рік тому +4

    Hi Striver,
    At the Section of Selection Sort.
    I believe there might be a bit misunderstanding on calculating the Time complexity part:
    If we are given n elements, then in the first pass, it will do n-1 comparisons; in the second pass, it will do n-2; in the third pass, it will do n-3 and so on. Thus, the total number of comparisons can be found by;
    - (n-1) + (n-2) + (n-3) + ..... + 1
    So i believe it should be : n(n -1)/ 2
    At the end the TC is O(n^2), but i thought this should be the approach.

    • @sdfsdf-f1j
      @sdfsdf-f1j Рік тому

      man you really dont know any maths , just open the bracket n2-n by 2 remove the constans and less imp terms and it boils down to n2 . ....

    • @Badmashiontopsystem
      @Badmashiontopsystem 2 місяці тому

      @@sdfsdf-f1j when you took the clickbait seriously - "For programming you doesn't need maths"

  • @deepak8720
    @deepak8720 Рік тому +1

    Understood.
    Thanks for your commitment. That in itself is amazing motivation to keep going.

  • @valiz2628
    @valiz2628 11 місяців тому +96

    its 2:20am at 10 am i have exam,so jai shree ram,aur jai baba raj

    • @Ankit-mg3ge
      @Ankit-mg3ge 6 місяців тому +2

      College which year ??

    • @cocacola37281
      @cocacola37281 5 місяців тому +4

      Kasa gya?😂😂

    • @valiz2628
      @valiz2628 5 місяців тому +1

      @@Ankit-mg3ge 3rd

    • @valiz2628
      @valiz2628 5 місяців тому

      @@cocacola37281 got an A grade

    • @BHUVANEESHGREWAL
      @BHUVANEESHGREWAL 9 днів тому +1

      Saaaamee lessgoooo 🎉🥳😂🥲🤣

  • @hareshnayak7302
    @hareshnayak7302 9 місяців тому

    Understood,thanks striver for this amazing video.

  • @phisicist7518
    @phisicist7518 2 місяці тому

    Understood. (doing this while pursuing BTech in Petroleum Engineering just to keep my non core solid. helping out a ton. hope to complete the whole sheet)

  • @prayushgiri6515
    @prayushgiri6515 Рік тому +1

    understood!!!
    Thanks Striver bhaiya

  • @GenetDesta-wz8iq
    @GenetDesta-wz8iq 3 місяці тому

    You are so smart and thank you so much, i learned in depth regarding the sorting algorithm from your lesson .

  • @umeshpawar7003
    @umeshpawar7003 4 місяці тому

    on point, easy to understand, depth in approach. overall great . thanks striver for your efforts

  • @MitaliMaurya-k4x
    @MitaliMaurya-k4x 6 місяців тому +1

    Thankyou for your efforts! Dsa scares me, but you are making it easy for me

  • @kirankumari-xx1rs
    @kirankumari-xx1rs 11 місяців тому

    Thank you Striver, I am in my first year but I am learning a lot from you.

  • @anishchhabra6085
    @anishchhabra6085 11 місяців тому +1

    Understood, great lecture.

  • @sahitid5570
    @sahitid5570 5 місяців тому

    Such a detailed and perfect explanation. Thanks a lot Striver!! Understood the concept really well.

  • @shaikmudassirali7202
    @shaikmudassirali7202 Рік тому +1

    Bro seriously Love You 💘💘

  • @yash_nigam182
    @yash_nigam182 5 місяців тому

    Really Thanks to You Sir , Got all my PRoblems Cleared in this Video

  • @muhammadzubair957
    @muhammadzubair957 Рік тому

    Good Explanation in the Sorting algorithm. Thanks a Lot❤❤ Strivers

  • @maltaparikh4255
    @maltaparikh4255 Місяць тому

    Amazing lecture😊🎉Thank u so much 💖

  • @shubhivishwakarma9331
    @shubhivishwakarma9331 Рік тому

    you are amazing
    all the sorting you taught looks very easy after watching your vdo

  • @066-roshankumar6
    @066-roshankumar6 Рік тому

    Best Sorting video until Now THanks bhaiya...

  • @rizwanshaikh4024
    @rizwanshaikh4024 10 місяців тому +1

    Understood, thanks STRIVER

  • @anjaliarya6534
    @anjaliarya6534 5 місяців тому +1

    understood. You explain in very lucid language

  • @MohsinAli-zg3hr
    @MohsinAli-zg3hr Рік тому +1

    UNDERSTOOD. Thanks for giving us this course!

  • @UserUser-tn8tv
    @UserUser-tn8tv Рік тому

    I just wanna say Thank U you are a big brother figure for me...

  • @AbhishekChaurasiya-op6pq
    @AbhishekChaurasiya-op6pq 7 місяців тому

    Understood everything and it became crystal clear topic

  • @suryaprakashiitbhu191
    @suryaprakashiitbhu191 Рік тому +1

    Striver, Your content is truly outstanding and incredibly informative! Always thank you for your relentless hard work and consistently delivering the best content.❤

  • @SupriyoPurkait-r8d
    @SupriyoPurkait-r8d Рік тому

    your explanation is just Awesome. UNDERSTOOD

  • @tvnalkkmgaargyreddy9548
    @tvnalkkmgaargyreddy9548 6 місяців тому +1

    Explanation is amazing 😍

  • @SatyaNadella-e7q
    @SatyaNadella-e7q 7 місяців тому

    You are the best man... I donot know where this energy come from...

  • @sangariprem2554
    @sangariprem2554 Місяць тому

    Thank you @Striver 😊 Understood

  • @chiranjeebpanda8926
    @chiranjeebpanda8926 7 місяців тому

    Understood. Best explanations for every sorting algo :)

  • @Riya_K-124
    @Riya_K-124 Рік тому

    Great explanation......clear cut explanation👏👏👏

  • @roshninv
    @roshninv Рік тому

    Completed the sorting - I , thank you for the breif explaination bhaiya.

  • @rohitkuttum3102
    @rohitkuttum3102 4 дні тому

    hi striver understood this concept perfectly !!!!

  • @priyanshishukla8334
    @priyanshishukla8334 3 місяці тому

    really the best course
    lots of love sir

  • @VishalYadav-gk1kg
    @VishalYadav-gk1kg Рік тому +1

    Very Nice explanation sir, Thank you!

  • @dhivyaviswanathan7604
    @dhivyaviswanathan7604 2 місяці тому

    great explanation ever..kudos🙂

  • @sampraveen9226
    @sampraveen9226 5 місяців тому

    27:35 while computing time complexity for worst case, we do n-1 swaps in 1st iteration then n-2 swaps in 2nd iteration then n-3 swaps in 3rd iteration ...... 1 swap in
    (n-1)th iteration so its 1+2+3+......+(n-2)+(n-1) now if we apply sum of n natural numbers we have to substitute n=n-1 so the formula becomes n(n-1)/2 and not n(n+1)/2 as u given. Thanks.

  • @mohammedharoon1167
    @mohammedharoon1167 5 місяців тому +1

    Amazing course 🤩

  • @shubha_jagadeesh
    @shubha_jagadeesh 4 місяці тому

    well understood 💞👍
    keep going ❤

  • @anujsamdariya984
    @anujsamdariya984 6 місяців тому

    Best Explaination of Insertion Sort!!!

  • @syeddanishabbas7274
    @syeddanishabbas7274 5 місяців тому

    Awesome work Striver! Much appreciation from Pakistan!

  • @everythingabout3479
    @everythingabout3479 6 місяців тому

    Thank you so much striver. Your each and every video is such nice 👍

  • @xenialzenagouge1781
    @xenialzenagouge1781 8 днів тому +1

    understood sir
    thankyou soo much

  • @aryankumararya1674
    @aryankumararya1674 5 місяців тому

    Thank you sir for your dedication and efforts.❤

  • @VipulSharma-j7t
    @VipulSharma-j7t 3 місяці тому

    05:28 Learn about selection sort and its key steps
    10:56 Selection Sort algorithm explained and pseudocode provided
    16:24 Selection sort algorithm explained
    21:52 Bubble sort pushes the maximum to the last.
    27:20 Bubble Sort - Implementation and Analysis
    32:48 Worst complexity of bubble sort is n^2, but can be optimized to best complexity of n
    38:16 Sorting technique of shifting and swapping
    43:44 Explanation of worst and best case time complexity of insertion sort.

  • @Mr.Manoj1
    @Mr.Manoj1 3 місяці тому

    Appreciate the efforts! Very clear explanation!

  • @m.swetha7340
    @m.swetha7340 7 місяців тому

    Understood sir❤ plz make more videos it's really helpful sir🙏

  • @saravananm588
    @saravananm588 5 місяців тому +1

    you're the best man🔥

  • @kingbadshah452
    @kingbadshah452 Рік тому +1

    thanks for this lecture ,,,, understood everything

  • @shashamnk2525
    @shashamnk2525 Рік тому

    folks that was 5:29 AM in striver's clock , please hit the like button for the efforts he makes for us , forever grateful.

  • @a_maxed_out_handle_of_30_chars

    simple and to the point, thank you :)

  • @NIKHILKUMAR-zg3us
    @NIKHILKUMAR-zg3us Рік тому

    understood
    Thank you so much for giving this fabulous course.

  • @Iqbal00123
    @Iqbal00123 Рік тому

    Take love from Bangladesh.Understood everything

  • @soniakakas887
    @soniakakas887 6 днів тому

    loved learning from you

  • @nileshchavan_23
    @nileshchavan_23 Рік тому +1

    Love you bhai❤

  • @abudeepa0474
    @abudeepa0474 4 місяці тому

    Awesome brother ❤ thankyou so much

  • @Delulu-Toons
    @Delulu-Toons Рік тому

    understood it way better than anywhere else

  • @devanshimishra9786
    @devanshimishra9786 6 місяців тому

    Thanks for this lecture finally understood those sorting techniques

  • @waqas3051
    @waqas3051 10 місяців тому

    Understood, Very well explained.

  • @Abiram77
    @Abiram77 12 днів тому

    understood every concept bro, thank you

  • @Ravi_477
    @Ravi_477 2 місяці тому

    Best teaching style

  • @andor_andor
    @andor_andor Рік тому

    Great work, Striver. Best Free Resource

  • @vijay_liftzz
    @vijay_liftzz 12 днів тому

    best video till date

  • @ReNaq313
    @ReNaq313 Рік тому

    Amazing approaches 🔥🔥

  • @SubhashKumar-bj5xd
    @SubhashKumar-bj5xd Рік тому

    I really appreciate your effort. And your videos are helping me a lot. thank you sir🙏