Counting Sort explained with animations and example | Full implementation and code

preview_player
Показать описание
Counting Sort is an algorithm which does not use comparison to perform sorting. It works in a O(n) time complexity but there is a certain caveat. It compromises on space to give you a better time complexity. Counting sort is usually applied with some special use cases when you know the range of elements beforehand. In this video watch a live demonstration how it works behind the scenes followed by a dry-run of the code. This way the concept will stay in your mind forever.

00:00 - Intro
01:14 - Where do you use Counting Sort?
03:43 - Live Demo of Counting Sort
11:04 - Dry-run of code
15:09 - Final Thoughts

📚 Links I talk about in the video:

💻 Get Social 💻

#algorithm #sorting #tutorial
Рекомендации по теме
Комментарии
Автор

Honestly, brother, you are godsent. Thanks so much for this video. You are one of the only channels I have seen that dry-run code together. I enjoyed every moment of this video

aliyanshaikh
Автор

So useful ! You explain amazingly well ! Keep it up !!

mariaghorayeb
Автор

Perfect, it's clear to understand. Appreciated 👏🏼

ssthil
Автор

Great job. Thank you very much for taking the time to careful explain the Counting Sort Algorithm. It is one thing to know, it is another to inform or impart knowledge. You have done so. Thanks again.

charlesopuoro
Автор

Gr8, thanks, could you please explain why cumulative and placing in output array with -1, should work

shortandshine
Автор

Great video by the way it was very helpful. Quick question though why do we have 6 occurances of 2 and just a single occurance of 3 when there should be 2 occurance of 3 and 5 of 2 when sorting the array for the final result?

mohamedndaloma
Автор

Very helful and very good explanation.. Thank you sooo much

ebrahimkassem
Автор

thanks for the knowledge and it will help me to do my assignment.

maisharana
Автор

Also for negative numbers how to make it work in python

shortandshine
Автор

Hi sir,

I have a doubt

If I have integer arry={1, 5, 2, 10, 11, 20}
If you sort this array using Arrays.sort() - > o/p 1, 10, 11, 2, 20, 5
Why it is sorting based on ASCII value?
Why not sequentially 1, 2, 5, 10, 11, 20

If you take list of string having alphanumeric type, how we can sort alphanumeric Ally.
I am not able to solve this.
Can you help me on this?

Arrays.sort()-

wish
Автор

Can you please make a video explaining and solving "The full counting sort" problem on hackerrank?

anniamatthews
Автор

Since we're also finding a maximum and minimum number in the array. Isn't there a time complexity also involved in that?

LiswinGeorge
Автор

you mentioned counting sort follows stable in video?what is mean by stable sir?

vinethasuresh
Автор

Hey nikhil, I saw a lot of videos related to counting sort, yours is very easy to understand. Keep the good work going. The only issue is, I found the audio was not up to your explanatory skills. So please do consider some improvements in audio

thellaidhinesh
Автор

Bad audio and doesn't account for negative numbers.

etiennedegaulle