Count Sort | C++ Placement Course | Lecture 20.1

  Рет қаралды 209,668

Apna College

Apna College

Күн бұрын

Пікірлер: 287
@rutvikrana512
@rutvikrana512 4 жыл бұрын
Counting Sort:- Pros: -Time Complexity O(N) - Compareless sorting Cons: -Limited Usage i.e for int -Memory Consuption Uses: - Sort numbers - find counts of letter from string - remove duplicate from string - find kth smallest or biggest element from array within O(N) time. HAPPY LEARNING :)
@rajmhatre20
@rajmhatre20 4 жыл бұрын
is your code working? if yes can you share the code here
@maulikshah28
@maulikshah28 4 жыл бұрын
@@rajmhatre20 Here you go brother: #include using namespace std; void countSort(int arr[], int n){ int k=arr[0]; for(int i=0; i arr[i]; } countSort(arr, n); // Printing for(int i=0; i
@celiafernandes9084
@celiafernandes9084 4 жыл бұрын
Thanks for enlightening
@johnwick-m4m
@johnwick-m4m 3 жыл бұрын
@@maulikshah28 Your code doesn't work
@synergy_944
@synergy_944 2 жыл бұрын
@@maulikshah28 .
@maulikshah28
@maulikshah28 4 жыл бұрын
The people who come up with these ideas of sorting algorithms are true legends How can they think so far
@vinayakd4444
@vinayakd4444 4 жыл бұрын
So true!
@kuldeeprane1469
@kuldeeprane1469 3 жыл бұрын
yes bro
@CarlJohnson-cb9xm
@CarlJohnson-cb9xm 3 жыл бұрын
Fuking legends
@shreechatane9215
@shreechatane9215 4 жыл бұрын
Voice of the instructor is so sweet😁
@ravikumaryadav4735
@ravikumaryadav4735 4 жыл бұрын
Yha to padh le bhai .
@mousinmulani6054
@mousinmulani6054 4 жыл бұрын
😂
@jamespottex5197
@jamespottex5197 3 жыл бұрын
@@ravikumaryadav4735 sahi kaha
@AvidWanderlust
@AvidWanderlust 3 жыл бұрын
Padh le chutiye
@Thee_Beyonder
@Thee_Beyonder 3 жыл бұрын
@@ravikumaryadav4735 😂😂😂
@anuragtyagi1111
@anuragtyagi1111 3 жыл бұрын
When God come to help poor students ❤️
@sahillabhshetwar2739
@sahillabhshetwar2739 3 жыл бұрын
emo boy
@shailendramaheshwari5471
@shailendramaheshwari5471 3 жыл бұрын
if(! willing to learn ) { return poor ; } else { return rich; }
@radhikaagarwal5502
@radhikaagarwal5502 3 жыл бұрын
Salute to the team🇮🇳! You all are really helping lots of students and has made education , fun to learn with easy explanation
@ayushgarg7609
@ayushgarg7609 3 жыл бұрын
ig, the size of count array could be k+1 and terminating condition of loop should also be (i
@chinmay_0518
@chinmay_0518 2 ай бұрын
Variable size cannot be given to array, to use variable size some other concepts are required
@DawoodRizwan-k7f
@DawoodRizwan-k7f 7 ай бұрын
You explaining so good...❤❤❤♥♥
@mohammadrafi895
@mohammadrafi895 2 жыл бұрын
We can create a count array of size (k+1) instead of size 10.
@Ace-ex9gg
@Ace-ex9gg 10 ай бұрын
no
@mohammadrafi895
@mohammadrafi895 10 ай бұрын
@@Ace-ex9gg Then explain the reason. Saying just 'no' doesn't contradict my statement.
@ankitwaghmare4007
@ankitwaghmare4007 4 жыл бұрын
The best things happen for students in 2020 is Aman bhaiya and his team come with this teaching facilities ....thank you bhaiya ..... Definately we will make you proud ...just wait ❤️❤️❤️❤️❤️❤️
@karanjaiswal4682
@karanjaiswal4682 4 жыл бұрын
dynamic array can be allocated : int* count = new int [ k ];
@deveshdubey6776
@deveshdubey6776 3 жыл бұрын
Thanks bro
@deveshdubey6776
@deveshdubey6776 3 жыл бұрын
Why mam said we can't dynamically allocate memory to count array?
@karanjaiswal4682
@karanjaiswal4682 3 жыл бұрын
@@deveshdubey6776 don't know why
@swostikpati7505
@swostikpati7505 3 жыл бұрын
Why did ma'am assign the size of count array as 10. Won't it cause problems if the actual size is greater than 10?
@karanjaiswal4682
@karanjaiswal4682 3 жыл бұрын
@@swostikpati7505 thats why I provided the code for dynamic array allocation
@anirudh3799
@anirudh3799 4 жыл бұрын
Bhai apni kaksha channel pe please biology daaalde yaar.Biology ke liye hee sab se zyada zarurat hai animation kaaaaa
@user-gt8ic3ti6l
@user-gt8ic3ti6l 2 жыл бұрын
why we need to find the maximum element of an array while after we initialise the count array size 10.
@dhruvchokshi8805
@dhruvchokshi8805 2 жыл бұрын
it can be sorted in javascript by performing this: arr.sort(function(a,b){return a-b})...this will return the same output
@KumarSahil78
@KumarSahil78 Жыл бұрын
This is normal sorting, in java and C++ also have these but the count sort is different.
@AliShair-f7q
@AliShair-f7q 5 ай бұрын
If you create an array on the heap, such as with int* arr = new int[n]; --> the time complexity is O(n). If you create an array on the stack, such as with int arr[n]; --> the time complexity is O(1).
@uttamkarmakarece3534
@uttamkarmakarece3534 3 жыл бұрын
Time complexity explained in only 2 minutes 😑...it should be explained in details But all over I love this playlist❤️
@parthapratimghose173
@parthapratimghose173 3 жыл бұрын
The trick I did is create Madeleine plus 1 as size of counter array that will solve future memory overflow
@aniketmani7502
@aniketmani7502 2 жыл бұрын
These sorting algorithms are really great. But still, you forgot about some legendary sorting techniques. 1. Bogo Sort 2. BogoBogo Sort 3. Miracle Sort 4. The Schrodinger's Sort
@divyam69
@divyam69 2 жыл бұрын
doo bee dooo beee dooo beee
@ChandanJobanputra
@ChandanJobanputra 2 жыл бұрын
Dont know why but my code is not giving any output Plz help
@rajiv-59
@rajiv-59 2 жыл бұрын
great work mam .............
@extremesatyaiitjeeair1980
@extremesatyaiitjeeair1980 3 жыл бұрын
// I think the final procedure (output array) is better in my idea void countSort(int a[],int n){ int k=a[0]; for(int i=1;i
@streetfood6183
@streetfood6183 4 жыл бұрын
Aman bhaiya... Unacademy plus IIT JEE subscription lene ke Baad kya... Hame class 11 Pura padhne k baad class 12 shuru hoga... Ya Phir dono parallel chalenge?
@marmikprajapati6681
@marmikprajapati6681 3 жыл бұрын
What if there are negative numbers in array? We can't use count array in that case!!
@heyitsanmolj
@heyitsanmolj 3 жыл бұрын
well, that's just not true. They have mentioned this before in some other video, you gotta use your brain tho. Make an array of length, -min(arr)+max(arr)+1 in case of negative numbers, and you can still do this!
@mayankbhardwaj3443
@mayankbhardwaj3443 4 жыл бұрын
Hlo sir Web design/web development ke course kabb aayenge🙄🙄🙄 Plz upload fast...i want to learn that🙏❤️
@kartikarora3521
@kartikarora3521 4 жыл бұрын
Bro if you want to learn it then I would recommend you to go to Mozilla Developer Network(aka MDN), it has open source content for learning web development/front-end development and it is made by Mozilla(The organisation that made Firefox Browser). And Bhiya will not upload web design because web design is related to graphic design it does not include coding. Front-end includes coding, which focus on coding the design and ui/ux made by a graphic designer. Web design and front-end are completely different
@mayankbhardwaj3443
@mayankbhardwaj3443 4 жыл бұрын
@@kartikarora3521 thx for the information 😉❤️
@maulikshah28
@maulikshah28 4 жыл бұрын
If you really want to learn, then you can but Angela Yu 's Web Development course on udemy. It is really not a bad investment for about 450 rupees I am also learning from it. I highly recommend it
@mayankbhardwaj3443
@mayankbhardwaj3443 4 жыл бұрын
@@maulikshah28 lol...why did u buy it😂😂....i downloaded it free ....😂😂😂want link?? Tell me 😂😂
@maulikshah28
@maulikshah28 4 жыл бұрын
@@mayankbhardwaj3443 really? How, tell me
@rishigupta9680
@rishigupta9680 2 жыл бұрын
i have doubt ki jab ki agr jab extra output array lena hi hai to direct count wale array se kyun nhi sort kr skte index ko padkdo or uski value ko tab tak push kro jab tak wo zero na ho jaye
@harshwasnik7636
@harshwasnik7636 4 жыл бұрын
Ohho... Wo last me "byee".. Maje aa gye
@irannapatil7050
@irannapatil7050 4 жыл бұрын
up to date i fallow this course and i feel and i know competitor of this course is not available on todays market.
@harsh461
@harsh461 4 жыл бұрын
My Code School is still the best
@dheerajbisht4096
@dheerajbisht4096 4 жыл бұрын
Then u haven't seen the market yet
@harsh461
@harsh461 4 жыл бұрын
@@dheerajbisht4096 Bhai tu thapar sa ha kya?
@dheerajbisht4096
@dheerajbisht4096 4 жыл бұрын
@@harsh461 no bro, ait pune
@irannapatil7050
@irannapatil7050 4 жыл бұрын
@@dheerajbisht4096 tu hi bol bhai kaha pe hai isse accha
@mohitrathaur9670
@mohitrathaur9670 Жыл бұрын
apka program nahi samagha pa rahe
@hustlewithVaibhav
@hustlewithVaibhav 4 жыл бұрын
Thank you didi🙏
@himanshudawande360
@himanshudawande360 3 жыл бұрын
I would be very happy if the Apna college team could reply to us and solve our doubts because sometimes even searching a lot also doesn't solve the doubts . Or if possible please explain the things like why are you declaring this variable and why are you adding it etc in the video itself. THANK YOU the course is awesome
@ketangupta221
@ketangupta221 3 жыл бұрын
I don't understand why we need to recursively add all the array elements for getting sum of elements till its previous elements. And then do that extra work of checking each number subtracting it and then putting it in array. We could have just taken elements from the count array which we had formed and just put those numbers in the array in ascending order according to their position in count array and their frequencies.
@lasbutious116
@lasbutious116 3 жыл бұрын
I have the same doubt. why make something simple so complicated?
@riyanshkhandelwal305
@riyanshkhandelwal305 4 жыл бұрын
What if there is any negative element in an array? How we will store it in count array? And I also think that size of the count array is one greater than the maximum element in an array arr.
@maulikshah28
@maulikshah28 4 жыл бұрын
This code will not work if there are negative elements
@manishmalhotra5883
@manishmalhotra5883 4 жыл бұрын
May use map then
@sourabhchoudhary7289
@sourabhchoudhary7289 4 жыл бұрын
can we create count array of size k+1(k=max element in array) i.e. count[k+1]?
@harpic949
@harpic949 4 жыл бұрын
Same doubt
@prince-kc6gq
@prince-kc6gq 3 жыл бұрын
working for k+1 but dont know whether it is logically correct or not
@aakashthakre244
@aakashthakre244 3 жыл бұрын
Same doubt and also mam ne k kyu nhi liya 10 kyu liya wo reason bhi nhi samjha 😭
@sourabhchoudhary7289
@sourabhchoudhary7289 3 жыл бұрын
@@aakashthakre244 I thik max+1 would work
@devjoshi7062
@devjoshi7062 3 жыл бұрын
@@aakashthakre244 Array size + 1 is the way to go for this algorithm as it gives extra breathing space for us to store numbers
@snehilsinha4689
@snehilsinha4689 3 жыл бұрын
I think the size of the count array should be k+1 and not k. I even tried coding it out and it works for k+1 but not for k. Please confirm this once. 🙏
@suhasshenoy4541
@suhasshenoy4541 3 жыл бұрын
yes because indicies start from 0 and kth index will be k+1 th element
@mayurschittaragi
@mayurschittaragi 3 жыл бұрын
I had the exact same doubt and was confused for a long time.. Thanks for clearing.😊
@snehilsinha4689
@snehilsinha4689 3 жыл бұрын
@@mayurschittaragi pleasure helping 😊
@moonalexfeneba6944
@moonalexfeneba6944 3 жыл бұрын
I think you can also take n, As when we put the value of the max element in the array, but in our array, we have many repetitions For example in this question max element is 6 but the no. Of element is 9=n-1 so our loop will work fine if we use i
@simransaini9079
@simransaini9079 2 жыл бұрын
exactly you solved my problem
@mrwordpress6676
@mrwordpress6676 4 жыл бұрын
Thanku urvi goel ma'am
@chahitbhardwaj3075
@chahitbhardwaj3075 2 жыл бұрын
Didi yeh batao ki yeh sabhi algorithm humko yaad rakhna hoga kya Thoda complex lag raha hai, agar yaad kare toh hum khud se algorithm kaise banayenge Pls reply...
@maccall0108
@maccall0108 4 жыл бұрын
please cover the topic 2D array Dynamically
@aakashthakre244
@aakashthakre244 3 жыл бұрын
Ha yaar
@gaishiya7696
@gaishiya7696 3 жыл бұрын
instead of allocating count array size as 10,we can use k+1 right ? actually that's why we are finding the max element .
@deveshdubey6776
@deveshdubey6776 3 жыл бұрын
Why mam said we can't dynamically allocate memory to count array?
@SaurabhKumar-ft3gt
@SaurabhKumar-ft3gt 3 жыл бұрын
same question..
@devjoshi7062
@devjoshi7062 3 жыл бұрын
idk why she did but looking for restricted memory prespective, you will surely get runtime error as it will reach past the maximum time allowed. Idk but still try, it can work also
@mitadey3876
@mitadey3876 4 ай бұрын
Can we skip the cumulative sum part and based on the index of count array add index of count array in original array.
@vrajeshmodi4928
@vrajeshmodi4928 3 жыл бұрын
There is one minor mistake in notes program ,You have to take 'k+1' as count array size. (Problem is in Line 6). Overall best course at KZbin for DSA loved it.
@faizanullah6922
@faizanullah6922 3 жыл бұрын
thanks dude 🙂
@aaryan__bondekar9778
@aaryan__bondekar9778 8 ай бұрын
yes, i had same doubt!
@nakulgite7565
@nakulgite7565 4 жыл бұрын
Do we need to learn data-structure and Algorithm first to complete this course.. pls reply🙏
@sourabhchoudhary7289
@sourabhchoudhary7289 4 жыл бұрын
This course will teach you DSA .
@maulikshah28
@maulikshah28 4 жыл бұрын
This course is of DSA, you don't need to learn anything before this
@piyushverma8207
@piyushverma8207 3 жыл бұрын
How did she do that. She printed the array in main function. But for all we know that she only sent the values of arr in the function without referencing it.
@aakashthakre244
@aakashthakre244 3 жыл бұрын
She stored the value in original array in function in last lines
@piyushverma8207
@piyushverma8207 3 жыл бұрын
@@aakashthakre244 You got that wrong. She could access the array from a function because arr is a pointer. If you try to do the same thing with an int variable, you will not be able to do that
@shivanshpratap3624
@shivanshpratap3624 3 жыл бұрын
@@piyushverma8207 GCC Compilers takes array in functions as a reference by default
@akashayanand
@akashayanand 7 ай бұрын
why is there overhead of creating a 'position array' our goal can be achieved from the count array itself. this code is not optimal?
@nishantgarg2815
@nishantgarg2815 3 жыл бұрын
can't you simply use count array to put numbers in new array since you know frequency of each number.Something like int k=0; for(int i=0;i0){ for(int j=0;j
@lasbutious116
@lasbutious116 3 жыл бұрын
I have the same exact question. will it not be a lot easier to create the new array because we already know the frequency of each element?
@iamkanishkyadav
@iamkanishkyadav 3 жыл бұрын
Because then Time complexity will become Big-O of N^2 ie O(n^2) . But we want optimal O(n).
@nishantgarg2815
@nishantgarg2815 3 жыл бұрын
@@iamkanishkyadav Its O(N) not O(N^2).Check again
@iamkanishkyadav
@iamkanishkyadav 3 жыл бұрын
@@nishantgarg2815 I am stuck, right now, but ur code is not simple O(n), may be something else. May be I need to go more depth in time complexity.
@lasbutious116
@lasbutious116 3 жыл бұрын
what if the range of data is big? suppose array=[100000,1,80] then except for these 3 values all 100000 variables will have count 0 but still we have to traverse through all of them
@deepakmodi9343
@deepakmodi9343 2 жыл бұрын
Nice explanation and a nice video.
@harshwasnik7636
@harshwasnik7636 4 жыл бұрын
Di will it work for negative values? Coz u can't store no. of times that element occurred. Please do correct me if I am wrong.
@thesomebody5439
@thesomebody5439 4 жыл бұрын
I guess we just have to mod the values
@hunterzolomon6842
@hunterzolomon6842 3 жыл бұрын
@@thesomebody5439 ni be lolu
@deveshdubey6776
@deveshdubey6776 3 жыл бұрын
counting sort is incapable of sorting negative numbers...but there is a modified counting sort which can do it
@abhijeetgautam587
@abhijeetgautam587 3 жыл бұрын
Find the minimum element of the array. Then declare an integer: int convert_factor = (0 - minElement); Now add convert_factor to every element of the original array. Then use the usual QuickSort algorithm and obtain the sorted array. Finally, before printing the sorted array, subtract convert_factor from each element of the sorted array.
@leo-x1d1f
@leo-x1d1f 3 жыл бұрын
in notes please correct count array size is max+1 that means k+1 but in note take only k which is wrong
@shubhamkale735
@shubhamkale735 3 жыл бұрын
When yoou are at another level of coding ......... Thank you aman sir and team ... l
@adityamishra8296
@adityamishra8296 2 жыл бұрын
maine same code likha tha not working😥😥
@NitishYadav-rb9ki
@NitishYadav-rb9ki 4 жыл бұрын
Web development ka course kab aayega
@fardinalam7290
@fardinalam7290 2 жыл бұрын
how could be time complexity is O(N)??? when she used first loop as a traverse whole array after that used 2,3 loops?
@sumitkevlani5740
@sumitkevlani5740 3 жыл бұрын
Hamne maximum Element nikalkar ke us length +1 ki array bnayi but suppose agar array me negative number aaya tab to yeh algorithm kaam nhi aayega
@gauravjha4209
@gauravjha4209 4 жыл бұрын
Bro plz help me how to improve Maths my maths subject is week but i hope u make a one video for us
@ashwinshetgaonkar6329
@ashwinshetgaonkar6329 3 жыл бұрын
we can allocate memory for dynamically for array,
@abhisheknishad2401
@abhisheknishad2401 4 жыл бұрын
Awsm mam
@makarandpundlik1083
@makarandpundlik1083 3 жыл бұрын
Can we sort -ve elements using this method ?
@AkshitPanday
@AkshitPanday 3 жыл бұрын
No this can be applied only on array with non-negative elements as frequencies cannot take -ve indexes
@abhijeetgautam587
@abhijeetgautam587 3 жыл бұрын
Find the minimum element of the array. Then declare an integer: int convert_factor = (0 - minElement); Now add convert_factor to every element of the original array. Then use the usual QuickSort algorithm and obtain the sorted array. Finally, before printing the sorted array, subtract convert_factor from each element of the sorted array.
@makarandpundlik1083
@makarandpundlik1083 3 жыл бұрын
@@abhijeetgautam587 great, that will work.
@jiosim1377
@jiosim1377 3 жыл бұрын
Isnt the time complexity of count sort O(n+k)?? Can someone explain please??
@sawanpatel3491
@sawanpatel3491 3 жыл бұрын
it's O(n)+O(k); but we are performing on large number of elements i.e. 10^7. so we ignore it.
@vinaywalia8723
@vinaywalia8723 4 жыл бұрын
there so many for loops so that can increase the time complixicity just asking
@sourabhchoudhary7289
@sourabhchoudhary7289 4 жыл бұрын
Actually O(n)+O(n) is approximately equal to O(n)!
@rambabupatidar3092
@rambabupatidar3092 3 жыл бұрын
how No of element in count array are coming from max element of arr array . For eg . If arr is 6,8,12,3,4,5,2,6 In this case k will come out to be 12 but acutually k must be 7 as there are only 7 distinct element in array.
@walwinvirlar6873
@walwinvirlar6873 4 жыл бұрын
I did not understand when she said we can't make dynamic array then 5 lines later makes a dynamic array of size n could someone explain to me how?
@aakashthakre244
@aakashthakre244 3 жыл бұрын
Same ques
@harendraseervi5525
@harendraseervi5525 3 жыл бұрын
#include using namespace std; int main() { vectorv; int arr[]={1,5,3,1,2,3,4,4,2}; int maxno=-55; for(int i=0;i
@minimaxhindi
@minimaxhindi Жыл бұрын
Please create a video on bucket sort
@aaryansaha9616
@aaryansaha9616 3 жыл бұрын
Can someone clear it ? How does count[ arr [ i] ] ++ ; work ?
@snehilsinha4689
@snehilsinha4689 3 жыл бұрын
basically, you are using the technique here called hashing in which you are making a new array to store the count of every element of the original array. This works in the following way -> 1. You are using the index number of the new array to represent the value of your array element i.e. arr[i] 2. Then you are incrementing on that index each time your element occurs in the array by doing count[j]++ where j=arr[i] works as the index. 3. Thus in this way the new array stores the count of each element of the array and its index helps identify the corresponding elements which will be useful while accessing it. Hope it helps 🙏
@monikaraut5266
@monikaraut5266 2 жыл бұрын
Here count is basically Array of counts, in which you are storing count of elements, you will store count of 0 at index 0, count of 1 at index 1 , count of 2 at index 2 and so on.. e.g. When you see 2, you will increment value at index 2 in count array
@nageshwarmitkar2708
@nageshwarmitkar2708 4 жыл бұрын
Bhaiya please suggest best videos for digital marketing.
@pritishpattnaik4674
@pritishpattnaik4674 4 жыл бұрын
can we do this by combination of vectors and pairs ?
@shubhamhelloworld321
@shubhamhelloworld321 3 жыл бұрын
Yessssss
@aakashthakre244
@aakashthakre244 3 жыл бұрын
Many doubts no solution on net also please tell us where to ask doubt so teachers can reply
@gandhijainamgunvantkumar6783
@gandhijainamgunvantkumar6783 2 жыл бұрын
Amazing explanation :)
@sahilbheke4083
@sahilbheke4083 2 жыл бұрын
6:56 why can't we take k as a size
@aaruljuneja4875
@aaruljuneja4875 4 жыл бұрын
Please🙏🙏🙏🙏 also make video on python language
@anuragpandey3341
@anuragpandey3341 3 жыл бұрын
FAANG Motivation video: 1day - 1million views Actual knowledge to crack FAANG companies: 1year - 50k views What's the use of motivation without hardwork?
@ishangupta9294
@ishangupta9294 3 жыл бұрын
totally agreed! everybody wants to work in FAANG but dont want to work upon what it takes to get there
@faizanahmed9304
@faizanahmed9304 Жыл бұрын
What for negative numbers?
@gauravdhiran9474
@gauravdhiran9474 3 жыл бұрын
Code is not printing any output , can you please give me the solution what can I do to get the output
@rudrakalyan4567
@rudrakalyan4567 Жыл бұрын
Thank you mam
@saswatsamal1199
@saswatsamal1199 3 жыл бұрын
why can the array be dynamically allocated at - 6:57
@sahilgupta7170
@sahilgupta7170 3 жыл бұрын
make array of size k+1 it will work
@bestluckstar2967
@bestluckstar2967 3 жыл бұрын
How can we apply the counting sort algorithm to sort array with negative numbers?
@shailendramaheshwari5471
@shailendramaheshwari5471 3 жыл бұрын
by taking the abs() value of the negative elements in an array
@saisriangajala8399
@saisriangajala8399 2 жыл бұрын
Why do we iterate from back why can't from front??
@depressinglyfunny
@depressinglyfunny 3 жыл бұрын
i have a doubt? why cant we make a dynamic array in the count sort function??
@siddharth4069
@siddharth4069 3 жыл бұрын
Counting sort only works when the range of potential items in the input is known ahead of time. If the range of potential values is big, then counting sort requires a lot of space
@avinashgupta2308
@avinashgupta2308 2 жыл бұрын
int count[K+1] --> why not this ? but count[10] this ?
@vijaysbuddhi5252
@vijaysbuddhi5252 Жыл бұрын
Guys how much time did it took for U complete this lec? Just asking
@aritraganguly3957
@aritraganguly3957 2 жыл бұрын
does count sort come in interview
@aakanshasoy3921
@aakanshasoy3921 Жыл бұрын
Last element me Garbage value show hora hai use kese solve kru ?
@sit33darshanpagar16
@sit33darshanpagar16 3 жыл бұрын
3:51 why we are decrementing and then storing value in array. 😔
@its_neel_ok
@its_neel_ok 3 жыл бұрын
cause we added the values to get the position. So, if we want the position in sorted order we have to go reverse(from end to start), we can' t do that from start to end
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 3 жыл бұрын
there is a problem with the code. when the original array size is less than the max element of the array, then the program crashes. For, ex;: arr[] = {18,1,8,1,20} here n = 5, but k = 20; so, array can't take elements if you can't handle correctly the size of the array inside the function. Wish much focus was given in the concept explanation than animation of the video
@shivanshpratap3624
@shivanshpratap3624 3 жыл бұрын
Why so?
@Abhishek-zx5zz
@Abhishek-zx5zz Жыл бұрын
Negative elements ma frequency kesa count kar payga
@satyamsingh3
@satyamsingh3 3 жыл бұрын
Bouncer bhai sahab
@angadchoudhary2773
@angadchoudhary2773 3 жыл бұрын
Can anyone explain the word at 6:57 ?
@pratham9954
@pratham9954 4 жыл бұрын
Why he is providing course for free even there are no ads in all course??
@AdityaKumar-pp4xw
@AdityaKumar-pp4xw 4 жыл бұрын
He has multiple channels too, Long term investment I guess
@mohammadanas7929
@mohammadanas7929 4 жыл бұрын
Thku mam❤️❤️
@sachinkashi
@sachinkashi Жыл бұрын
What if there are negative numbers also included to be sorted
@mbasimirfan5465
@mbasimirfan5465 Жыл бұрын
ye hi to masla aa raha
@Yahy_Sani
@Yahy_Sani 2 жыл бұрын
#include using namespace std; int main() { int n; cin >> n; int a[n]; int N = 0; for (int i = 0; i < n; i++) { cin >> a[i]; N = N < a[i] ? a[i] : N; } int countArr[N + 1] = {0}; for (int i = 0; i < n; i++) { countArr[a[i]]++; } int k=0; for (int i = 0; i < N+1; i++) { for (int j = countArr[i]; 0
@ayushmishra1396
@ayushmishra1396 10 ай бұрын
What if the value of element of array is -1
@rohanupahyay3791
@rohanupahyay3791 4 жыл бұрын
Notes??
@shreyasingh4680
@shreyasingh4680 2 жыл бұрын
what if the array contains negative elements?
@higgsboson3882
@higgsboson3882 Жыл бұрын
then you would have to find the minmum element and make array accordingly for eg -3 -1 1 3 4 5 so count array will have 0 1 2 3 4 5 6 7 8 where 0 stores occurences of -3 , 2 stores occurences of -1 ... so on
@vashishthgajjar1968
@vashishthgajjar1968 4 жыл бұрын
wait what kind of sorting method is this?
@ServingTech
@ServingTech 4 жыл бұрын
In Your Coount_Sort Program You Cannot Sort The Negative Values.
@yashgandhi9698
@yashgandhi9698 4 жыл бұрын
can be done using origin shifting if a mixture of both +ve and -ve just reverse the sign in case of all negative...
@ServingTech
@ServingTech 4 жыл бұрын
@@yashgandhi9698 #include using namespace std; void Count_Sort(int arr[],int n, int Min,int Max,int ans[]) { int range=Max-Min+1; int farr[range]={0}; for(int i=0;i n; cout > arr[i]; Max = max(arr[i], Max); Min = min(arr[i], Min); } int ans[n]; Count_Sort(arr,n,Min,Max,ans); for(int i=0;i
@ServingTech
@ServingTech 4 жыл бұрын
Like This ?
@csiddharth380
@csiddharth380 4 жыл бұрын
Bhaiya G plz is video k bhi notes upload krdo
@sakshithakur8465
@sakshithakur8465 4 жыл бұрын
Please upload notes 🙏🏻🙏🏻🙏🏻
@pranshuprapranshu304
@pranshuprapranshu304 7 ай бұрын
you didnt told why you started , loop from i=1 and not from i=0 (~_~)
@TRICK_OF_THE_DAY
@TRICK_OF_THE_DAY Жыл бұрын
Why you don t have Persian subtitle?
@shravakjain5163
@shravakjain5163 3 жыл бұрын
how can we think so far like that..? i am unable to solve new question
@jiosim1377
@jiosim1377 3 жыл бұрын
Bro all these sorting algorithms are standard algorithms u cant think on spot nd get the logic. U have to learn and remember the logic
@aadil4236
@aadil4236 Жыл бұрын
What happens if there are negatives?
@Ayush_.
@Ayush_. Жыл бұрын
fir to map leke hi solve krna padega🤓
DNF Sort | C++ Placement Course  | Lecture 20.2
8:33
Apna College
Рет қаралды 115 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Count Sort Algorithm
27:05
CodeWithHarry
Рет қаралды 130 М.
8.3.1 Sorting in Arrays | Selection Sort |  C++ Placement Course
8:32
Apna College
Рет қаралды 1,1 МЛН
Radix Sort | Easiest explanation with example
6:05
Gate Smashers
Рет қаралды 461 М.
Learn Counting Sort Algorithm in LESS THAN 6 MINUTES!
5:59
CS Dojo
Рет қаралды 367 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 735 М.
Learn Quick Sort in 13 minutes ⚡
13:49
Bro Code
Рет қаралды 431 М.
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Abdul Bari
Рет қаралды 2,3 МЛН
Lecture16: Selection Sort [Theory + Code] || C++ Placement Series
34:29
CodeHelp - by Babbar
Рет қаралды 564 М.
DSA & ₹1.2 Crore Per Annum Jobs - The Truth? (No Offence)
12:22
CodeWithHarry
Рет қаралды 757 М.