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

preview_player
Показать описание

Discussed Counting Sort Algorithm with its Code.
Step by step guide showing how to Sort an Array using Count Sort. Analysis of Counting Sort (Time Complexity)

******************************************
See Complete Playlists:

***********************************************

Connect & Contact Me:

#countingsort #jennyslectures #dsa
Рекомендации по теме
Комментарии
Автор

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

rahuldey
Автор

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!

Chadagon_of_the_Swolen_Order
Автор

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!

andrey.smolennikov
Автор

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

noorbajwa
Автор

This is the best explanation of counting sort PERIOD.

mayanksingh
Автор

This is the best explanation for Count Sort you will come across in YouTube.

davidarputharaj
Автор

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

study-meoe
Автор

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.

bardamu
Автор

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]

siddharthkshirsagar
Автор

Easily one of best algorithm teachers on youtube.

alexmiserandino
Автор

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

UnknownNiks
Автор

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.

nickharalampopoulos
Автор

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!!

liamsnide
Автор

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!

Hello-vtbh
Автор

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.

durumarthu
Автор

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

BSEss
Автор

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.

_vrushabhjadhav
Автор

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

Mandeep
Автор

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

anubhavkumar
Автор

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.

izzyv