Well, counting sort is typically used on integers as we are collecting the frequency of each integer in the array. But, if you would like to do a modified version that instead counts the occurrence of strings, you'd have to first map each string to an index (hashing) and then apply it as shown in the video. However, note that this would not be optimal at all if your array does not contain a lot of frequently repeated strings. Let me know if this answers your question!
BEST video I've stumbled across so far on explaining the counting sort algorithm. Really helps to see actual code with the video. Thank you!
Thanks a lot!! Glad it helped :)
thanks a ton for covering more use cases than simpler one. Really good. !! Hope more people come here and this channel grows !!
Thanks for your kind words they're much appreciated!
this was amazing
you are simply the best
Brilliant
can u explain how this sort works for strings??
Well, counting sort is typically used on integers as we are collecting the frequency of each integer in the array. But, if you would like to do a modified version that instead counts the occurrence of strings, you'd have to first map each string to an index (hashing) and then apply it as shown in the video. However, note that this would not be optimal at all if your array does not contain a lot of frequently repeated strings. Let me know if this answers your question!
@@geekific yeah, thanks :)
Amazing video but do keep that in mind that these two algorithms are not stable.