Insertion Sort in C Language (With Explanation)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • How to code Insertion Sort easily in C: After watching this video you will be easily able to code insertion sort in c. Implementation of insertion sort in C is pretty straight forward and easy and this is what we will see in this video!
    ➡Download Source Code & Notes here: codewithharry....
    ➡Join this DS & Algo course & Access the playlist: • Data Structures and Al...
    ►Checkout my English channel here: / programmingwithharry
    ►Click here to subscribe - / @codewithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Python Tutorial In Hin...
    ►Python Complete Course In Hindi - • Python Tutorials For A...
    ►C Language Complete Course In Hindi -
    • C Language Tutorials I...
    ►JavaScript Complete Course In Hindi -
    • JavaScript Tutorials I...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Django Complete Course In Hindi -
    • Python Django Tutorial...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithhar...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

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

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

    Thanks a lot ...for your efforts Harry sir .....aapko bhgwan khoob trkkki de ye meri dil se dua HH......kafi mehnt se bnate ho aap vidio .....

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

      Hlo brother

    • @UlT989
      @UlT989 7 หลายเดือนก่อน +2

      Kitne logo ko pata hai harry ka nam harris Ali khan hai

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

    27:13 bohot ache se samaj me agya
    And a lot of big thanks for this amazing Explaination.

  • @Ahmed_king777
    @Ahmed_king777 ปีที่แล้ว +17

    Even better explanation than apna college

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

    Harry Sir.. its a humble request to u plz continue your machine learning playlist to some intermediate or advance level concepts.. I would be very thankful to you... 😄😄

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

    9:40. So sweet of u sir u anyhow manage to convey ur teaching to the needies🥺🥺...

  • @amanswaraj6377
    @amanswaraj6377 2 ปีที่แล้ว +8

    Seriously, you go the extra mile to explain the concepts, the dry run was very nice!

  • @anexocelisia9377
    @anexocelisia9377 2 ปีที่แล้ว +9

    With the help of two pointers ( Iterators) we simply take element by element from the right side of the partition and j will get decrement towards left side untill it either it becomes negative or will become less than key
    Once this is done then we'll increase the partition and hence this way it will add an element at the appropriate place.

  • @Mohit-fe5hx
    @Mohit-fe5hx ปีที่แล้ว +2

    Harry bhai pura din k baad last m aapke paas aake samajh aaya....last m while loop m se nikalne nhi aa rha tha ..j=-1,nhi kr pa rhe the..finally pura clear ho gya!!LOVE YOU

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

    Thankyou so much for your efforts in making all these videos and teaching us all these concepts for free... It helps us alot... Thankyou so much... God bless you and stay safe Harry bhaiyya...❤️😇🤗

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

    Ha Harry Bhaiya insertion sort bariya se samaj me aa gaya dry run ne bohot help kia specially.

  • @35aganeshkad4
    @35aganeshkad4 3 ปีที่แล้ว +8

    Harry thanks for your effort for making this lecture. very brilliant explanation

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

    Please make another tutorial in Java playlist

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

    Bahut ache se samaj aagaya maine c pura apse hi sikha hai aur c++ bhi adha se jyada hogaya hai aur dsa bhi yaha tk pahuch gaya hu

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

    Explaination is very amazing ...With set mind...All query clear in one video A lot of big thanks sir....Keep Doing.

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

    Thanks big brother! Thanks for teaching me for several years! I hope that u will stay safe!

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

    You're an phenomenonal explainer 🔥

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

    Hello bhai you are master in coding i am learning coding by your videos you
    Are my best teacher

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

    You are best 💯 for last 3 hours I was dry running this code .. But you solved my problem within 10 minutes

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

    // my Logic for Insertion Sort
    void insertion_Sort(int *array, int n)
    {
    for (int i = 0; i < n - 1; i++) // possibilty for comparing every element to its precedings
    {
    for (int j = i + 1; j > 0; j--)
    {
    if (array[j-1] > array[j])
    {
    swap(&array[j-1], &array[j]);
    }
    }
    }
    }

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

      I did the same but used while loop inside the for loop

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

    Thanks a lot for such explanation. Was unable to understand this concept, but after your explanation I can easily do it !!

  • @ArshadKhan-ld9tr
    @ArshadKhan-ld9tr 2 ปีที่แล้ว +1

    My approach...
    void swap(int *i, int *j){
    int temp = *i;
    *i = *j;
    *j = temp;
    }
    void insertionSort(int *arr, int size){
    for(int i = 0; i < size-1; i++){
    //printf("%d pass
    ", i+1);
    for(int j = i; j >= 0; j--){
    if(arr[j+1] < arr[j]){
    swap(&arr[j+1], &arr[j]);
    }
    }
    }

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

    Thank you for this amazing course 🥰😍🙏🏻🙏🏻

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

    For my java friends :
    package DataStructureAndAlgo;
    public class insertionSort {
    static void insSort(int[] a1){
    /*-1 is for that we need to sort ont n-1 elements because the remaining element
    will be already sorted*/
    for(int i=0;i=0 && a1[j]>key){
    //make the element after j to same as j
    a1[j+1]=a1[j];
    //check the condition for the remaining sorted elements if they are bigger than a1[i]
    j--;
    }//after this loop exits the value of j will be -1, so we will add one, so it becomes 0 then will replace it with our key
    a1[j+1]=key;
    }
    }
    static void printArray(int[] a1){
    for (int element:a1 ) {
    System.out.print(element+", ");
    }
    }
    public static void main(String[] args) {
    int[] e1 ={2,7,9,5,57,34,35,657};
    insSort(e1);
    printArray(e1);
    }
    }

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

    Hey, hello Harry sir,
    You have changed my thinking of world :)

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

    def insertionSort(self, arr):
    if(len(arr) > 1):
    for i in range(1, len(arr)):
    for j in range(i-1, -1, -1):
    if(arr[j] > arr[j+1]):
    arr[j], arr[j+1] = arr[j+1], arr[j]
    else:
    break
    print(arr)
    else:
    print(arr)

  • @warriorx1526
    @warriorx1526 24 วันที่ผ่านมา

    thanks for the video harry bhai , it was very clear explaination of insertion sort in detail done by you ,we hope you go on top in it sectors

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

    your explanation is just so amazing 🙂🙂🙂.

  • @nishaathakurr
    @nishaathakurr 6 หลายเดือนก่อน

    Woww!! I appreciate how you took extra time to explain the concept..❤

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

    Harry Bhai such much Aasanise
    Samja aya Insertion sort🤗🤩

  • @priyagupta-qr8tv
    @priyagupta-qr8tv 3 ปีที่แล้ว +2

    your videos are extremely helpful please make videos on angular projects and .net project real time projects.. Your channel is the best..🖤🖤🖤love the way u explain...

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

    Harry bhai ekdm diwali dhamaka de rhe hai😘

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

    Aap itne achhe se explain karte ho, concepts to crystal clear ho hi jayega.❤️❤️❤️❤️

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

    Finally understood. Thanks a lot

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

    Great Explanation Harry Bhai ,hope i have teacher like you in my college time.👍

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

    Thanks harry bhai for this perfect explanation of insertion sort

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

    Sir plz make a course on game developement with unity plzzz

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

    Samaj me Aya sir
    Lots of thanks for this explanation.

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

    Thank you So much for a beautiful explanation💖💖.
    Just because of you we can tackle viva n practical examination after pandemic...

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

    What an amazing explaination!
    Thank you so much Sir.❤️❤️

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

    Great explanation .Thank you for this course.

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

    Smjh mai aa gaya👍

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

    Dry Run clear all doubt thanks a lot sir!!!!😍

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

    mindblowing sir marvelous mja aa gya fantabulous sir 🥰🥰😍😍

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

    Harry bhai u r life line of coders.❤️💜

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

    *INSERTION SORT*
    def printArr(arr):
    for i in arr:
    print(i,end="\t")
    print()
    def insertionSort(a):
    for i in range(1,len(a)-1):
    key=a[i];
    j=i-1;
    while(j>=0 and a[j] > key):
    a[j+1]=a[j];
    j-=1;
    a[j+1]=key;
    if __name__=='__main__':
    a=[7,10,2,6,9];
    print("array before sorting");
    printArr(a);
    print("array after sorting");
    insertionSort(a)
    printArr(a)

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

    Insertion sort algorithm samaj mein aagaya, Thank u so much Harry Bhaiyya 💖

  • @VaniPandey-s8b
    @VaniPandey-s8b ปีที่แล้ว +1

    Appreciatable work ❤👏👏keep it up its very help full

  • @prasadprashantb.4001
    @prasadprashantb.4001 2 ปีที่แล้ว

    Ha bhai samaaj gaya🙌🤟bahut badiya content dete ho bhai❤❤❤

  • @VikashKumar-ox2hv
    @VikashKumar-ox2hv 3 ปีที่แล้ว

    Mind-blowing bhaiya , I will say firstly I thought it's easy to understand then, later on I thought it getting complex ( when you said > ) but later on you made the it so easy to understand .
    Thank you very much bhaiya , you language you attitude I follow it from the Start of your TH-cam channel you didn't change yourself that's the thing makes me surprise .

  • @user-nm4vn9tq5o
    @user-nm4vn9tq5o 3 ปีที่แล้ว +1

    Samajh aagya Harry Bhai , thanks a lot

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

    Thanks For the well and best algo and code for insertion sorting.

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

    harry sir,just one question ,if we start the loop from 0 to less than n-1
    will it run?

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

    Bhai what is meant by int in coding you u have written in coding

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

    dry code run was veryy helpful thank you soo much

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

    Sir, I am Yash me aap ko request karta hu ki aap python ko idle me video ko banaye or Kuch project ko be. please sir ye Mera humble request hai aap ko...

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

    Samj mein aa gaya Harry Bhai .👍

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

    Bhaiya as you say that after watching this video you will fully understand the concept, I will must say that yes I understood it very well and now I can also explain it to others also. Thank you very much

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

    Love it .... Best session

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

    Sir make videos on rust programming language

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

    You are genius and best coder in the world.

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

    best explanation Harry bhai👍

  • @NITISHKUMAR-vu8gy
    @NITISHKUMAR-vu8gy 3 ปีที่แล้ว +1

    sir tree or graph pura complete kar dijiye gaa sir..........please

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

    Sir I am having some problem in using the escape sequence in the line no 8 print statement.I find it to be more useful when I use it on line no 6 right after the %d

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

    Very well Explained Harry Bhai 💌

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

    sir ekdam samaj ma aagaya hai..

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

    Boss ek doubt clear kijiye,ye data structures c language k liye hai ya sabhi language k liye

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

    Samajh me agaya !!!
    THANK YOU SOO MUCH HARRY BHAI

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

    Samajh mai aa gya sir insertion sort 😎.

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

    bhai acche se samajh aa gaya hai insertion sort

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

    Thanks bhai bahuth ache se samaj aaya

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

    Log pagal ho gye hai... Pata nahi kya kya demand kr rhe hai harry bhai se.... Are thori to apni samjh lagao bhai wo ek insaan hai and apna best deni ki koshish kar rha hai.. And give him his time he will make all the things... Have patience and be a good subscriber😊

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

    Sir, want full course on laravel framework....plz...plz.....
    The people who want a course on laravel
    like..... request from Bangladesh....

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

      I am also from Bangladesh.....Need a Laravel course..
      and We love you sir....😍😍😍

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

      @@programmercr7618 Where are you from...Mane Bangladeshe kothae bari..

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

    Harry bhaiya done with this thank you 27:01

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

    East or west harry bhai sabse best ❤❤❤

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

    Very very easy ... because of you ... salute you

  • @SaiRajVadeghar-i8o
    @SaiRajVadeghar-i8o 7 หลายเดือนก่อน

    dammn !! the explanation just penetrated right in my brain .

  • @mo.hasnenmobinchavhan104
    @mo.hasnenmobinchavhan104 2 ปีที่แล้ว

    Samaj me aagaya harry bhaiya 100%

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

    After watching this Insertion sorting has became a cake walk for me.

  • @841sanjanaramgarhia4
    @841sanjanaramgarhia4 10 หลายเดือนก่อน

    Seriously it is worth it ❤

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

    Great bhai u r just awesome👍👍

  • @SachinPCD-Telugu
    @SachinPCD-Telugu ปีที่แล้ว +1

    Well understood bro.

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

    harry bhai.. maan lo while loop mein 1st time mein.. jab ( j = 0 ) hai.. uss time sorting hui to fir ( j - - ) ki value fir kya hogi???????

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

    I wish i could have teachers like you in my college. You are amazing.

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

    Smajh mai agaya harry bhai.

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

    Sir bohat ache se samajh me aa gaya😍😍💙💙💙

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

    I will get clearly understand this topic ....thank u harry bhai

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

    27:13 Harry Bhai Samajh me aagaya

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

    Thank you 😊

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

    Harry Bhai,Smjh Mai Aagya!!

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

    got it very easily harry bhai

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

    harry bhai i must say thanks for itna sara content i was really scared ki 2 year me fail ho jaungi ds me but you rae life saver thanks

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

    Samajh gaya, Harry bhai!!

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

    Sir,
    Plz make React JS tutorials

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

    very brilliant explanation

  • @rameshwarpatil-bn6qb
    @rameshwarpatil-bn6qb หลายเดือนก่อน

    thank you sir for this video.

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

    Great sir lots of efforts made by you thankyou so much sir

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

    You are phenomenal!!

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

    samjh mai aa gya harry bhai

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

    thanks bhaiyya it was splendid

  • @KDrama_Hindi-w7t
    @KDrama_Hindi-w7t 2 ปีที่แล้ว

    You are the best 👍💯 i was watching Apna College video that video was also good but not more than this. As you used a key variable makes this code easier to underestand