7.12 Counting Sort (Analysis and Code) | Easiest Explanation | Data Structure Tutorials

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

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

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

    I think Jenny is the best on TH-cam when it comes to explaining complex sorting algorithms. Count sort and Merge sort explanation by her is outstanding.

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

    You did an amazing job at explaining this.
    As others said, your explanation was crystal clear.
    The fact that you fully explained each step before writing the code was also really cool because that way you can understand the code way better.
    Thanks for sharing!

  • @andrey.smolennikov
    @andrey.smolennikov 4 ปีที่แล้ว +8

    I have spent hours to understand why we do running sum before final placement and you are the only one who explained it SO CLEARLY! Thank you so much!

  • @noorbajwa1845
    @noorbajwa1845 9 หลายเดือนก่อน +1

    Mind-blowing no one teaches these complex things better than you,I'm loving to code because of you

  • @study-me1oe
    @study-me1oe 5 หลายเดือนก่อน +2

    Wow, this is the best video I've seen for count sort. And also provided some keen drawbacks with a quick solution for sorting negative numbers too.
    One thing I would like to add is, we can improve the count sort by reducing the k value by "mapping the elements of the array" to some smaller values.
    Eg: if we have an array like 683,610,672,699,601,642. Instead of creating a count array of size 699+1, we can create a smaller array by subtracting the smallest value 601 from all elements ⇉ 82,9, 71,98,0,41. Now we can create count array of size 99 instead of 700.
    We can improve the feasible range of K this way

  • @izzyv830
    @izzyv830 2 หลายเดือนก่อน +1

    Im leaving a comment for algorithm cuz its honestly criminal that this isnt the first video when you search for counting sort. Its literally the only one ive found that presents it in a way that makes sense.

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

    This is the python code for this astounding explanation.
    And you delivered the algorithm so flawlessly, thank you.
    def counting_sort(array):
    n = len(array)
    k = max(array)
    count = [0] * (k + 7)
    output = [None] * (n)
    for i in range(0,n):
    count[array[i]] += 1
    for i in range(1,k + 1):
    count[i] = count[i] + count[i - 1]
    # count[i] += count[i - 1]
    for i in range(n - 1,-1,-1):
    output[count[array[i]] - 1] = array[i]
    count[array[i]] -= 1
    for i in range(0,n):
    array[i] = output[i]

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

    Counting sort can be confusing. Switching between the index, the element value, different arrays... Jenny manages to make it all so easy to understand. And enjoyable too. That half and hour passed quicker than an episode of Southpark. Liked and subscribed!!

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

    Great job! Very informative and crystal clear. I have gone through many videos trying to explain counting and radix sort aglorithms but none is as easy to understand as this one. Jenny has great teaching skills in elaborating on critical details and giving first the big picture. I wish all teachers would have the same skillset and approach. Most of the time, it is not because things are difficult that we do not dare to explain them in pedagogical manner, it is because we do not dare to peel out things in more comprehensible chunks that things are difficult.

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

    This is the best explanation for Count Sort you will come across in TH-cam.

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

    Thank you so much. This is the best explanation of the counting algorithm. It helped me particularly when you explained why we should start form the last element of the original array.

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

      she said so" to maintain the stability"

  • @Hello-vt2bh
    @Hello-vt2bh 10 หลายเดือนก่อน

    Your clear explanation of the counting algorithm was incredibly helpful. The step-by-step breakdown before delving into the code enhanced my understanding significantly. It's the most comprehensive explanation of counting sort I've come across after exploring multiple sources. Keep up the excellent work!

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

    I watch this video 3 times then i uderstand the example with code.
    The best teacher i have ever see in may engineering life thanks henny man for very deep and very accurate explanation love you from maharashtra.

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

    Your explanation is so awesome and thank you for not overlooking all the small intermediate steps so that it’s understandable by anyone with varying degrees of knowledge and understanding of this topic. Also thanks for implanting the logic alongside. Awesome job! Clear and precise explanation. I’m subscribing.

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

    aap Devi ho , itna accha to hume kisi ne bhi padaya ...thanks a lot

  • @mayanksingh7814
    @mayanksingh7814 3 หลายเดือนก่อน +1

    This is the best explanation of counting sort PERIOD.

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

    Saw your video first time..... And i became a huge fan ma'am..... The way you explained every tiny things in detaaill.... Was just outstanding....

  • @immortalsofar7977
    @immortalsofar7977 4 ปีที่แล้ว +19

    I actually learn something from Jenny's lectures, unlike my university professors. Keep up the great work! Greetings from Vancouver, Canada

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

      looks like university profs are terrible world wide huh

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

    The way she teach is so clean , easy to understand for me even my english is limited. thanks from vietnam

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

    Easily one of best algorithm teachers on youtube.

  • @SamiKhan-sb5ik
    @SamiKhan-sb5ik ปีที่แล้ว +3

    00:02 Counting sort is a non-comparison sort algorithm that sorts elements based on their keys.
    02:38 Counting Sort is applied when the array contains no negative values and the values are in the range of 0 to K.
    07:44 The video explains the process of counting sort.
    10:30 Counting sort involves finding the actual position of elements in the sorted array.
    15:52 Counting Sort is a stable sorting algorithm.
    18:17 To maintain the stability of the sorting algorithm, start from a particular index and decrement the values
    22:53 Counting Sort is a sorting algorithm that places elements in a sorted array using a count array.
    25:24 Count Sort is a linear time sorting algorithm that can sort elements in a given array.
    30:22 Counting Sort limitations and the need for Radix Sort
    Crafted by Merlin AI.

  • @hariomvitthala
    @hariomvitthala 3 หลายเดือนก่อน +1

    You are simply flawless.... loved your teaching methods!! Thanks a lot ma'am 🎉🙏

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

    Really is best explanation of "The Counting Algorithm" !!!

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

    Best and clear explanation of Counting sort available on net.

  • @saritakumari-oh8fs
    @saritakumari-oh8fs 4 ปีที่แล้ว +2

    It was a mistry for me until I see your explanation. Thank you

  • @ron6107
    @ron6107 4 ปีที่แล้ว +7

    This was amazing! Awesome! You not only covered a LOT more than covered in similar lectures but your explanations were lucid and to the point. Thanks!

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

    The best explanation for counting sort!

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

    very well explained, Thanks Maam
    Respect from Pakistan

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

    Love you mam you are the best one who teaches this topic in very simple manner ❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️

  • @Mdt-24
    @Mdt-24 5 หลายเดือนก่อน

    Thank you very much, i got confused with the cumulative counting array part, the other videos ive watched didnt really go into depth on how it worked to index the numbers to its correct places. Your video made me grasp this very quickly so again, a massive thank you.

  • @umarrabiuel-yakub4690
    @umarrabiuel-yakub4690 4 ปีที่แล้ว

    at first I was saying the content is too long for me but believe me is worth waiting thank you xx you are the best

  • @kavitasavitamourya6202
    @kavitasavitamourya6202 4 ปีที่แล้ว

    Mam u r best apke samjhana ka tarika the way u explain the concept mujhe bahot accha lagta he or apke samjhana me ek clearity he jiske wajhese bahot jaldi samjh me aata he 😊👍👍👍👍
    Thank u so much mam😇

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

    My slow brain magically caught up to the idea of counting sort.
    You are a wizard, Jenny.

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

    East & West Miss Jenny is BEST ! , North & South Everyone is out !!!

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

    This is the best illustration of counting sort i have seen.

  • @Justsimransingh
    @Justsimransingh 4 ปีที่แล้ว +6

    I am watching your dsa series from long time but literally... You are amazing seriously your knowledge is damn good your concepts are so clear and the way you explain each and everything is remarkable. The stability concept constrain me to comment you deserve to be appreciate...
    I am preparing for my placement I am a B.Tech Final Year Student and you are helping me a lot I shared your playlist with all my college friends because the best dsa series is By Jayanti Khatri Lamba on Jenny's Lecture.
    A big thanks to you for helping me ❤️

  • @ABHINAVKUMAR-vh3ln
    @ABHINAVKUMAR-vh3ln 3 ปีที่แล้ว +1

    Clear and deep explanation. Worth watching 30 min video. Everyone should watch it once and you will never forget Counting Sorting, at least the nice mam here haha. Nice explanation mam by the way.

  • @sripriyanagaraju7019
    @sripriyanagaraju7019 4 ปีที่แล้ว

    Excellent teaching dear.
    Now on words , I am a big fan of you.
    Really Hatsof to you. Great Job.
    Heartly Thanks Alot.

  • @MahbubaPoly-c6u
    @MahbubaPoly-c6u 3 หลายเดือนก่อน

    OMG😲...your explanation😘 i have no word to say🥹🥹😘😘😘😘😘😘😘😘😘
    God bless you mam❤

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

    This was the best of counting sort explanation. Thank you so much for this amazing video.

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

    I have attended the best university in the world throught Jenny lectures. Thank u ma'am. Your teaching is the best.

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

    your videos are very helpful to me during my exam times ....the day before exam i only used to listen your videos ...u explained each and every concepts so nicely.. i just love your teaching ... thank you so much mam for all these videos :) :)

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

    Good Counting sort explanation available in YT.
    P.S Tried all other channels and came here.

  • @Άκης-θ2ε
    @Άκης-θ2ε 3 ปีที่แล้ว

    man we need teachers like her , great job

  • @shehryaramin1481
    @shehryaramin1481 4 ปีที่แล้ว

    Life Saver ...Big Respect from Pakistan !!!!

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

    Excellent Mam , And Thanks from Bangladesh . I am very much helpful from this video .

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

    In this video Computer Science Engineering In Its Peak Level By The Help Of an Awesome Professor! Your Explanation is best Madam...! #Respect_From_Calcutta

  • @joseardila1457
    @joseardila1457 4 ปีที่แล้ว

    This is so far, the best explamation that I had seen. Amazing video. 😬😬😬

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

    Excellent explanation I ever heard in my whole life...

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

    Thank u ma'am it helped a lot and your way of explaining is very descriptive which makes it easy to understand

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

    Thank you very much , explained very clearly , no chances of having any doubts , reminded me of real class in this time of boring online classes

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

    2hrs of cls in just 30mins❤ that too with clear cut explanation 🙏🙏

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

    absolutely in admiration of your teaching style, thank you so much!!

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

    Great explanation! This has a lot of application in terms of questions and really tricky to grasp.

  • @sidharthpanda8557
    @sidharthpanda8557 5 ปีที่แล้ว

    31 minutes is worth. Thanks for the simplest explanation.

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

    i love how you say "for" 😘😘 Nice explanation 👌👌👌👍👍👍

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

    Thank you! You're doing a brilliant job 😬

  • @muhammadfaizsam8852
    @muhammadfaizsam8852 4 ปีที่แล้ว

    thank u so much. i literally finding and watching so many videos but i have got my ans from here with clearly and briefly

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

    thank you maam.. You are a perfect example of "beauty with brain"

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

    Thanks a million Ma'am 👍🙏God bless you 😇

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

    you are best teacher for me the way you explain is just wow
    thank u very much mam

  • @sripriyanagaraju7019
    @sripriyanagaraju7019 4 ปีที่แล้ว

    Your so genius Sweety.
    You have thorough knowledge in subject/topic.
    I am really appreciating you.

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

    When everything fails...Jenny's Lecture just smash like Dhoni at last to win the match(exam)...❤️
    Thank you so much

  • @_-6912
    @_-6912 5 ปีที่แล้ว +3

    You have covered important concepts. You are an excellent teacher

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

    wow thanks jenny for using an all-encompassing example!

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

    jenny i love u take this ummah ummah 😘😘😘😘 no lecture would teach this subject better than u (getting educated + with gorgeous teacher )is adipoli comination

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

    beauty with brain,,,,,,awesome combination mam with respect.......

  • @vipul1246
    @vipul1246 4 ปีที่แล้ว

    I am an art student and didn't understand a dime but i like watching madame.I will watch all her videos.

  • @raman-jn6yt
    @raman-jn6yt 4 ปีที่แล้ว +1

    you never fail to make an impact on learning something !!! Thanks for your efforts !!! Looking forward for your other videos...

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

    chaala baga chepparu madam..very good explanation amma

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

    Excellent,
    Executed in java and was successful.
    public class CountingSort {
    public static void main(String[] args) {
    int[] a = { 2, 1, 1, 0, 2, 5, 4, 0, 2, 8, 7, 7, 9, 2, 0, 1, 9, 4, 6, 2, 3, 6, 5, 8, 7, 4 };
    //int[] a = {432,8,530,90,88,231,11,45,677,199};
    //This will take more space and time if done with counting sort , so we use radix sort
    int numberOfElements = a.length;
    int maximumInRange = getMaxInArray(a);
    countSort(a, numberOfElements, maximumInRange);
    }
    private static void countSort(int[] a, int size, int maximumInRange) {
    System.out.println("Before Sort :");
    for (int i = 0; i < size; i++) {
    System.out.print(a[i] + " ");
    }
    System.out.println();
    int[] count = new int[maximumInRange + 1];
    for (int i = 0; i < size; i++) {
    ++count[a[i]];
    }
    for (int i = 1; i = 0; i--) {
    b[--count[a[i]]] = a[i];
    }
    System.out.println("After Sort :");
    for (int i = 0; i < b.length; i++) {
    System.out.print(b[i] + " ");
    }
    }
    private static int getMaxInArray(int[] a) {
    int max = a[0];
    for (int i = 1; i < a.length; i++) {
    if (a[i] > max) {
    max = a[i];
    }
    }
    return max;
    }
    }

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

    great ma'am. u r blessing to all CS students

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

    Great explanation! Thank you! Especially thanks for explanation hot to make this sort stable.

  • @jithinmv6516
    @jithinmv6516 5 ปีที่แล้ว

    Best explanation I have seen so far for counting sort, It is just perfect mam :)

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

    always heard recommendations about your channel, now I do know why. That was awesome, thank you)

  • @premverma8220
    @premverma8220 5 ปีที่แล้ว

    bhatreen isse gazab kisis ne bhi ni padhaya aaj tak

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

    You are a best teacher ❤️❤️❤️ love from Pakistan 😘🥰❤️

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

    Amazing mam, i came across your channel during my interview prep, i am at microsoft usa now :)

    • @lovleshbhatt7797
      @lovleshbhatt7797 4 ปีที่แล้ว

      can you please give me a referral ?? I am good at DSA

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

    Well explained mam ...beauty with the brains

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

    Awesome explanation, teaching and patience level in teaching is highhhhhhh

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  5 ปีที่แล้ว

      Thank you for recognizing my contribution. I really appreciate your encouragement and kind words

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

    Thanks for sharing! Really good explanation. I loved watching every second of this video. Keep making more tutorials like this.

  • @therealaspirant1882
    @therealaspirant1882 5 ปีที่แล้ว

    very good explanation the same implementation i saw in coreman book happy that you are one who refered textbook before making video

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

    Thank you Jenny for your clear lectures!

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

    I wish to reiterate my thanks for such a good explaination.

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

    I have ever seen such a super explanation

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

    what an amazing explanation, you are the best at this . many thanks to you ❤👏👏👏

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

    Mam you are so talented and also worked hard to makes these videos

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

    Mam u are great!! i want you to be my teacher.......

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

    just brilliant. Thanks for the explanation!!!! cant be more gratefull...

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

    Thank you for the nice explanation. I have a qualifying algorithm exam and this helps me a lot!

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

    Thanks mam great explanation by the way u r looking gorgeous loved ur video

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

    Hey, you are teaching superb, this video is very useful to my university education. Thank you so much.

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

    Thank you for this!!! You are the best. Very insightful and comprehensive.

  • @satyamebjayate3730
    @satyamebjayate3730 4 ปีที่แล้ว

    very nice & simple explanation . ...really it's very useful. .. .Good job Jenny

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

    Best explanation so far!!

  • @CHANDANKUMAR-dc9eh
    @CHANDANKUMAR-dc9eh 5 ปีที่แล้ว +1

    thanks mam ,u just saved my ada paper, lots of love from mp......

  • @zeeshanmughal9413
    @zeeshanmughal9413 4 ปีที่แล้ว

    Thanks mam, your explaining skills are very eloquent.

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

    Clear cut Explanation. Thanks so much

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

    I am from pakistan your teaching method is so good mam you are briliant and keenly thoughts about the students complexity that'why you give a very nice lecture really inspired

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

    best video on count sort. wow!