Insertion Sort Algorithm - Theory + Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น •

  • @KunalKushwaha
    @KunalKushwaha  5 หลายเดือนก่อน +6

    DSA + interview preparation playlist: th-cam.com/play/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ.html

  • @pavan5524
    @pavan5524 3 ปีที่แล้ว +353

    I wish teachers from my college watch these videos and learn how to teach dsa! 😶

    • @vedanthbaliga7686
      @vedanthbaliga7686 3 ปีที่แล้ว +22

      Im not attending my college classes😂after this course. It's a surprise you still attend classes

    • @SKILLCRYSTAL
      @SKILLCRYSTAL 3 ปีที่แล้ว +16

      After watching this course I ask cross questions to faculty , it's really fun😂

    • @vedanthbaliga7686
      @vedanthbaliga7686 3 ปีที่แล้ว +3

      @@SKILLCRYSTAL same😂

    • @pavan5524
      @pavan5524 3 ปีที่แล้ว

      @@vedanthbaliga7686 the point was, you'd attend if a teacher like Kunal was teaching 😂

    • @ashreynahar8456
      @ashreynahar8456 3 ปีที่แล้ว

      @@vedanthbaliga7686 same 😅

  • @ankit_1012
    @ankit_1012 3 ปีที่แล้ว +71

    Teaching in the simplest way possible yet most effective way of teaching.I'll prefer to binge watch your videos rather than prime/Netflix....

  • @fv5895
    @fv5895 3 ปีที่แล้ว +63

    first time in my life I was able to solve 3 leetcode medium questions in one attempt. Thank you bro.

  • @akshaytakrani6886
    @akshaytakrani6886 3 ปีที่แล้ว +98

    When kunal teaches, the concepts are crystal clear ❤️

  • @karmatsering158
    @karmatsering158 3 ปีที่แล้ว +38

    His teaching materials should be distributed to all the online professors.

    • @anishaa3298
      @anishaa3298 2 ปีที่แล้ว +1

      HA HA HA HA HA

  • @devanshtiwari178
    @devanshtiwari178 9 หลายเดือนก่อน +2

    Your explanations themselves are so good that I code the algorithms myself. Before following this playlist I used to think that these algorithms have to be learned and now I laugh at myself

  • @chiragvohra6673
    @chiragvohra6673 3 ปีที่แล้ว +23

    Every time kunal is saying don't worry about complextity,One thing I want to say to Kunal In binary Search You have covered more time complexity than other youtuber's whole complexity lecture. Even you are saying I will make a Complexity video on this. That's why You are gem to us.😉😉

    • @gautamjha928
      @gautamjha928 ปีที่แล้ว +5

      yes, you are right.....i am placed in paytm just by watching his entire DSA playlist

  • @sainaid
    @sainaid 4 หลายเดือนก่อน +2

    whenever the time complexity concept comes, kunal everytime saying "i have covered it in previous lectures, why i am saying it again and again!" makes me repeat it with him

  • @vaibhavyadav2674
    @vaibhavyadav2674 3 ปีที่แล้ว +63

    Bhaiya can't wait to watch your next playlists on web development , machine learning , and many more
    Had become big fan of yours 😍😍

    • @KunalKushwaha
      @KunalKushwaha  3 ปีที่แล้ว +16

      Glad to hear that

    • @SonaliSingh-jy8pw
      @SonaliSingh-jy8pw 10 หลายเดือนก่อน +1

      @@KunalKushwaha please pls pls do a playlist for mern stack - webd

  • @Mohit_Gupta24
    @Mohit_Gupta24 8 หลายเดือนก่อน +3

    One observation - for every pass we are sorting pass + 1 elements of array i.e. when pass = 0(i = 0), 2 elements are sorted.
    This sort happens using swapping technique which can be visualised as ''Bubble sort in reverse' - basically here we are swapping in reverse order - like compare adjacent element and swap and repeat :)
    So the min element of array comes at first index position of array as a part of this swap.

  • @RajeshKR-q3y
    @RajeshKR-q3y 17 วันที่ผ่านมา

    Your tutorials are helping many tech people it's like a gem , please do not stop complete the whole algorithm concepts

  • @srideepkundu3221
    @srideepkundu3221 4 หลายเดือนก่อน +2

    I was taught insertion sort in my high school. Never understood and always made some mistake due to logic error. After this lecture I feel satisfied fr. Thank you Kunal.

  • @HARSHKUMAR-g2d6u
    @HARSHKUMAR-g2d6u 10 หลายเดือนก่อน +1

    You are the best teacher in the entire world to learn about the Data Structure and the algorithm

  • @undergroundartist6069
    @undergroundartist6069 ปีที่แล้ว +1

    your god for me brother no one teaches like you....teachers from our college never teach us like your teaching...Thank you

  • @Raavan-07
    @Raavan-07 2 ปีที่แล้ว +1

    after watching 8-9 different videos of insertion sort from every source but won't be able to understand the internal working of insertion sort. But finally, when I saw your detailed explanation of the insertion sort video, it cleared my all doubts. Thanks, Kunal Kuswahaaa...

  • @sreesamudrala5188
    @sreesamudrala5188 2 หลายเดือนก่อน

    If concepts were taught this clearly in college, Data Structures wouldn’t seem difficult to anyone. Amazing work, Kunal-you’re fantastic!

  • @sohamsattigeri1750
    @sohamsattigeri1750 3 ปีที่แล้ว +2

    The best thing about the lecture is amount of time given to explain the algorithm to the time given to coding

  • @shiwanithagele4544
    @shiwanithagele4544 2 ปีที่แล้ว +1

    from zero interest in coding to solving questions from my end ... you always help me thank you so much ... and god bless you with more happiness and success.

  • @sainaid
    @sainaid 4 หลายเดือนก่อน +1

    this insertion sort i found a bit tough than other sorting algorithms but you made it easy to understand for me.
    thankyou once again for providing this amazing dsa playlist. 😊

  • @shubhamagrawal78
    @shubhamagrawal78 2 ปีที่แล้ว +6

    Hey Kunal! Loving your way of explanation and the way you make difficult concepts easier and simpler is beyond expectation. I learnt a lot from your videos, I learnt indentation, writing clean code, logic building and what not. Please complete this playlist as soon as possible. It will be beneficial for everyone who started this series hearing your words that this is the only course you need to get a job at FAANGM.

  • @nehagadekar7381
    @nehagadekar7381 3 ปีที่แล้ว +2

    Everything seems so easy when u teach some people are deliberately making taboo of it is so difficult I am thankful to you for this quality content 👍

  • @DevGuy1234
    @DevGuy1234 4 หลายเดือนก่อน +2

    Happy Teacher's Day, Kunal!!!
    Thanks for teaching us!!

  • @Mr_Kaif__
    @Mr_Kaif__ ปีที่แล้ว +1

    I just understood that what I have to do and then I made the code logic by myself.
    Thank you so much Kunal bhaiya.

  • @ashwinikalyan9437
    @ashwinikalyan9437 3 ปีที่แล้ว +9

    Literally binge watching your content 🙌🙌

    • @KunalKushwaha
      @KunalKushwaha  3 ปีที่แล้ว +4

      Hope you enjoy!

    • @ashwinikalyan9437
      @ashwinikalyan9437 3 ปีที่แล้ว +1

      @@KunalKushwaha LOVE THEM SO MUCH THANK YOU!!!GOD BLESS YOU YOU PURE SOUL

  • @owaisnazirdar3575
    @owaisnazirdar3575 3 ปีที่แล้ว +20

    I Don't Know How To Thank You But I Am Sharing It Through All My Social Media Platforms

    • @KunalKushwaha
      @KunalKushwaha  3 ปีที่แล้ว +9

      Thats more than enough for me

  • @detexter3143
    @detexter3143 3 ปีที่แล้ว +2

    dont believe him guys...anyone watching this video just go once through the comment section you will not need more proof that this is the best course on the internet and he has the best teaching skills.... i am an idiot, i hated dsa but the way he teaches it makes me motivated to keep on doing and know what, i am improving my problem solving.... he not only teaches dsa but also the most important skill which is problem solving and how to approach a problem. just believe in this course and keep on solving and supporting this channel.

  • @suvraneelsaha8973
    @suvraneelsaha8973 2 ปีที่แล้ว +3

    25 mins explanation 5 mins of code
    loved it

  • @sumit8806p
    @sumit8806p 3 ปีที่แล้ว +9

    I used to watch and learn daily from this course but haven't done anything past 15 days. Hope I continue to learn from today. 🙂

  • @charugullasairitvik3099
    @charugullasairitvik3099 3 ปีที่แล้ว +1

    entire insertion sort explained clearly in detail and with good explanation...

  • @lostt3435
    @lostt3435 2 ปีที่แล้ว +3

    hey, very detailed video Kunal. Got every bit of it. Thank you to put your time and efforts into this. Nobody explains dsa in this much of depth. Thank you😊

  • @gautampoddar7785
    @gautampoddar7785 3 ปีที่แล้ว +6

    Doing a great job! Always needed a good playlist I could depend for DSA placement prep!

  • @vedanthbaliga7686
    @vedanthbaliga7686 3 ปีที่แล้ว +3

    3 videos in under 24 hours🤯thanks Kunal. Idk how you do this😬

  • @mayankgupta9988
    @mayankgupta9988 ปีที่แล้ว

    Best Explanation video for Insertion Short I found on TH-cam 🤩

  • @sujaydey9160
    @sujaydey9160 2 ปีที่แล้ว +3

    Usually I don't comment but you made me to like and comment in your videos. You owe me man. Also enjoying your DevOps stuff parallelly. Ahh one thing I want to let you know, I gave my computer networking exam by just watching your networking video twice, nothing else and I nailed it 😉. Hope to meet you one day ❤️

  • @priyankashaw1238
    @priyankashaw1238 2 ปีที่แล้ว

    Your explanations are so detailed that I'm usually able to write programs without even seeing your code.

  • @D.S.Apkare
    @D.S.Apkare 2 ปีที่แล้ว +1

    Kunal Sir
    Thanks for this video as well as for code and notes from GitHub
    It helped me very well
    You explain very well that anyone can understand from age 2 to age 90. There can also understand who don't know to read and write and only Know English
    Thanks for providing this
    ☺️☺️

  • @SatyamKumar-lj5bi
    @SatyamKumar-lj5bi 3 ปีที่แล้ว +3

    Kudos to you for uploading soon ! ❤️❤️

  • @Mansisinghal1234
    @Mansisinghal1234 4 หลายเดือนก่อน

    this course deserves millions of likes

  • @Ankurkumar-jr2ro
    @Ankurkumar-jr2ro ปีที่แล้ว

    you taught the concept so well that now my Genetics also know Insertion sort. Hence my grand children will also be good in sorting now.

  • @vikaspanwar5194
    @vikaspanwar5194 3 ปีที่แล้ว

    Watched this video during viva and explained this algo well to my teacher.
    Thanks kunal bhai

  • @ravindraverma8413
    @ravindraverma8413 ปีที่แล้ว

    The way to explain complexity is awesome.

  • @Helly_Patel
    @Helly_Patel 2 ปีที่แล้ว +1

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

  • @KaisarAnvar
    @KaisarAnvar ปีที่แล้ว

    The hardest problem I faced in your lecture was 2D matrix array. I always return back to that video to grasp the details, otherwise everything is CRYSTAL clear!

  • @HomesickCoder
    @HomesickCoder 3 ปีที่แล้ว +1

    Bhaiya just one word for uh, thankyou guru ji , wishing you a beautiful life ahead I'll meet you one day ❤️

  • @hemanthsavasere934
    @hemanthsavasere934 ปีที่แล้ว

    Hope Kunal brings out more quality content like these. Loved this

  • @arshsandhu5707
    @arshsandhu5707 ปีที่แล้ว

    His explanation was so good that i was able to write the code myself before checking his ❤❤❤

  • @santoshkumarpandey8372
    @santoshkumarpandey8372 2 หลายเดือนก่อน

    I compare this against 3-4 folks and by far KK's desc is awesome

  • @charlesopuoro5295
    @charlesopuoro5295 ปีที่แล้ว

    Another great video Kunal. You are the man. Thanks for your charitable endeavours.

  • @dhworld9428
    @dhworld9428 ปีที่แล้ว

    Kunal u r great person I wish every teacher watch this vdo and tech him students this way🎉

  • @abhiraj533
    @abhiraj533 2 ปีที่แล้ว +1

    Awesome content.. Not every educator can ease concepts out as simple as you do. Keep educating ...

  • @swooshruti
    @swooshruti ปีที่แล้ว

    It is amazing to learn every step so wonderfully explained by you

  • @GOKULK-ll8ur
    @GOKULK-ll8ur ปีที่แล้ว

    best explanation bro explained everything that it take only five minutes to code myself

  • @piyushkhandelwal1662
    @piyushkhandelwal1662 3 ปีที่แล้ว

    Sir you are awesome your explanation is great and one thing i write sir in my every comment because you are like my mentor a real teacher 🤗🤗🤗🤗🤗🤗🤗🤗🤗🤗

  • @masroorshah4968
    @masroorshah4968 3 ปีที่แล้ว +1

    won't come easier than this! great explanation

  • @kush_anju
    @kush_anju 3 หลายเดือนก่อน

    Thank a bunch kunal literally my doubts are not Doubt yet😅

  • @saurabhjaswal21
    @saurabhjaswal21 2 ปีที่แล้ว

    Great Explanation

  • @alexA-zf4mk
    @alexA-zf4mk 2 ปีที่แล้ว +1

    thank u for ur amazing efforts ,it really helped me to understand dsa topics

  • @shashianand9330
    @shashianand9330 ปีที่แล้ว

    Thanks @Kunal Kushwaha for creating me a better CS student

  • @shuklshivam
    @shuklshivam 2 ปีที่แล้ว

    Amazing video @kunal. (Concepts == cleared) -> true

  • @abhineveash
    @abhineveash 8 หลายเดือนก่อน +1

    awesome video

  • @Iron.agrawal
    @Iron.agrawal 9 หลายเดือนก่อน

    Superb explanation. Absolutely amazing.

  • @sojuu.11
    @sojuu.11 6 หลายเดือนก่อน +1

    Great teacher.

  • @akhiluniyal9455
    @akhiluniyal9455 ปีที่แล้ว

    Thanks kunal that explanation was epic, I was struggling in understanding this concept.

  • @bekamengesha8527
    @bekamengesha8527 2 หลายเดือนก่อน

    Superb explanation🎉🎉🎉🎉🎉

  • @PROTECHRAHUL
    @PROTECHRAHUL 3 ปีที่แล้ว +1

    Kunal bhai Is rocking 😎

  • @Content_creater_entertainment
    @Content_creater_entertainment 5 หลายเดือนก่อน +1

    Best playlist ever

  • @sanjairs6934
    @sanjairs6934 2 ปีที่แล้ว

    As a beginner,I felt this is better than CLRS pseudocode.

  • @akhilreddybollu5551
    @akhilreddybollu5551 2 ปีที่แล้ว +1

    I love the way you teaching 😍😍🥰🥰

  • @tolulopemalomo8922
    @tolulopemalomo8922 ปีที่แล้ว

    You explained this so clearly, thank you!

  • @vishalparashar4976
    @vishalparashar4976 ปีที่แล้ว

    after you explain i just code it myself thanks sir

  • @sakshijain9637
    @sakshijain9637 3 ปีที่แล้ว

    Ur amazing just completed watching selection sort

  • @noogaer4798
    @noogaer4798 ปีที่แล้ว

    Hey @KunalKushwaha I think this is not the Insertion sort. What we are doing here in the video is a reverse bubble sort. ----------------------> Please correct me, if I am Wrong.
    Reverse bubble sort means ---------> we are popping the smallest element to its correct Position.
    BTW: Code for Insertion sort...…. From ChatGPT
    .......................................................................................................
    public static void insertionSort(int[] arr) {
    int n = arr.length;
    for (int i = 1; i < n; ++i) {
    int key = arr[i];
    int j = i - 1;

    /* Move elements of arr[0..i-1], that are
    greater than key, to one position ahead
    of their current position */
    while (j >= 0 && arr[j] > key) {
    arr[j + 1] = arr[j];
    j = j - 1;
    }
    arr[j + 1] = key;
    }
    }
    .........................................................................................................
    I guess you will replace this Video ASAP. If you feel i am correct.

  • @cindrasenareddy1929
    @cindrasenareddy1929 2 ปีที่แล้ว +1

    gurujii!!!!!!!!!!!!!!!!! u are great

  • @Education..29071
    @Education..29071 11 หลายเดือนก่อน

    Such a great way of explanation Thanks a lot bhaiya😊❣️

    • @aaryanraj8342
      @aaryanraj8342 11 หลายเดือนก่อน

      @aryangaming8665
      why j>0 in this code plz explain

    • @Education..29071
      @Education..29071 11 หลายเดือนก่อน

      @@aaryanraj8342 becoz j is starting from i+1 and j-- everytime so if j will come to 0 then j-- result in Array outofbound condition

  • @nagarjunaakkisetty6801
    @nagarjunaakkisetty6801 2 ปีที่แล้ว

    Great Kunal sir I loved your explanation man

  • @rajsumanth9
    @rajsumanth9 7 หลายเดือนก่อน

    Super explanation ❤😊

  • @Jashu-er7gs
    @Jashu-er7gs 11 หลายเดือนก่อน +1

    Thankss kunall

  • @ashwinikalyan9437
    @ashwinikalyan9437 3 ปีที่แล้ว +2

    Boy's on fireee 🔥🔥🔥

  • @aritrachatterjee147
    @aritrachatterjee147 3 ปีที่แล้ว +7

    Hey Kunal I commented on the last video also ,, it's good that you are uploading in a regular basis ❤️ my question is will there be any long video like the one of binary search where u explained every possible topic questions... Will there be that kind of video for sorting? Just wanted to ask thanks ❤️

    • @KunalKushwaha
      @KunalKushwaha  3 ปีที่แล้ว +6

      Yes there will be many over the course, because sorting is combination of many concepts

  • @anmolsharma9539
    @anmolsharma9539 3 ปีที่แล้ว +1

    24:49 what did he say 😂
    Just for fun , great lecture kunal learned a lot from it.

  • @viper_jiggly_zt
    @viper_jiggly_zt 10 หลายเดือนก่อน +1

    My Man(kunal) stand by what he says 😮‍💨😍

  • @user-code404
    @user-code404 7 หลายเดือนก่อน +1

    there is one more implementation of Insertion sort in which the overhead of swap function is avoided.:
    public static int[] optimizedInsertionSort(int[] nums){
    if(nums.length == 0) return new int[0];
    else{
    for (int i = 1; i< nums.length; i++){
    int key = nums[i];
    int j = i- 1;
    while(j>=0 && nums[j] > key){
    nums[j+1] = nums[j];
    j--;
    }
    nums[j+1] = key;
    }
    return nums;
    }
    }

  • @nagendratalari1002
    @nagendratalari1002 3 ปีที่แล้ว

    Kunal on 🔥.... thank-you ji

  • @82hariharan
    @82hariharan 3 ปีที่แล้ว +1

    Clearly explained. Thank you.

  • @KshitizAnand-xr1wj
    @KshitizAnand-xr1wj 4 หลายเดือนก่อน

    I liked this video very much.

  • @ShivamDubey1
    @ShivamDubey1 3 ปีที่แล้ว +1

    Now, Kunal is in Form 😎

  • @goswamianshuman
    @goswamianshuman 3 ปีที่แล้ว +1

    amazing as always ❤❤

  • @malavipande6693
    @malavipande6693 2 ปีที่แล้ว

    ThankYou Kunal G!😇

  • @rutvik_mahant
    @rutvik_mahant 5 หลายเดือนก่อน

    Thank you the concepts are very clear now

  • @dillirajtimalsina
    @dillirajtimalsina 3 ปีที่แล้ว

    you said "make sure you comment" thats why i commented otherwise i am in rush to watch next video of this series!

  • @ankitchauhan7091
    @ankitchauhan7091 ปีที่แล้ว

    Le Kunal: Explains previously taught topic again ;whenever used
    After Expalining,
    Kunal: Why am i telling this agian and again

  • @aniketmore1410
    @aniketmore1410 8 หลายเดือนก่อน

    Your explanation is very good ! 😊😊. Can anyone suggest some project using these sorting algorithms?

  • @10raunakdubey7
    @10raunakdubey7 2 ปีที่แล้ว

    bro superbbbbb loving yrr this palylist

  • @utkarshsinghal5011
    @utkarshsinghal5011 3 ปีที่แล้ว +1

    insertion sort crystal clear

  • @yatinchauhan1710
    @yatinchauhan1710 ปีที่แล้ว

    finally i understood the insertion sort.

  • @architkumar1265
    @architkumar1265 3 ปีที่แล้ว +1

    Hey Kunal, just want to appreciate your efforts. I love your videos and these videos are actually making my concepts more strong. There was a quick question of mine that is it essential to buy any book for Java or your video lectures and notes are sufficient for placement purpose and other open source contribution purposes...????🙄

  • @amansayer4943
    @amansayer4943 ปีที่แล้ว

    i dont know why i was facing problems in binary search but after that all the sorting algorithms are fine . i think binary search should be learned after sorting .

  • @wheatleyOX
    @wheatleyOX 2 ปีที่แล้ว

    perfect explanation! thank you very much

  • @Vaishnavi0810-j3i
    @Vaishnavi0810-j3i 3 หลายเดือนก่อน

    Thanks you brother ❤