The algorithm is the same. You need to adjust the length variable to be: int length = sizeof(array)/sizeof(int); Other than that, nothing should need to change
I love watching your videos, I was just curious if we take this problem statement to a next level where .. what if a certain number occurs for the same number of time as that the other i.e., if arr[]={1,2,2,3,3} ; , if we go by the above mentioned algorithm, we will just get max_value as 2 and max_occurrence as 2 which will be unfair to 3 which too occurs for the maximum number of times that is 2 . What can we do to print all the most occurring number as well as their occurrences in such cases ? 😅, I tried but can't come up with an optimal solution .
This is a great question but completely answering it might be too long for what I can cover in a UA-cam comment. :-) I think we would need to store each "max value" in an array. Whenever we find a max value with occurrences greater than the existing max value, we would wipe out whatever is in the array and this value would become the new and only max value. But if we find a new max value with a "tying / equal" amount of occurrences, we would add it to the array of values instead. And then when we're done checking all the elements in the array we could output whatever is in the "max values array". That would be the general idea. Another way would be to count the occurrences of "everything" and store the results into an array of structs where each struct stores the value and number of occurrences, and then sort that array of structs by the number of occurrences, and check using the sorted array to see if there are any values that share the maximum number of occurrences. :-)
How to write this program? Write a c program to read a sentence from user and then remove all articles from it and display the updated sentence. Eg. Input:An apple a day. Output:apple day.
I can give you some hints: look into strtok, strcmp and set a list of strings that contains all articles. You can set such a list like this: char mylist[NUMBER_OF_ARTICLES][MAX_LENGTH_OF_ARTICLES]
What if we wanna find the most frequent number in an array and we don't know the number?
The algorithm is the same. You need to adjust the length variable to be: int length = sizeof(array)/sizeof(int);
Other than that, nothing should need to change
You can obtain the length of an array so it's possible to determine the frequency of any number
if in array two values are hold max occurance ,how to manage it
THANK YOU VERY MUCH SIR.
I REALLY LOVE TGE WAY U EXPLAINED.
I'M DEFINITELY SUBSCRIBING TO THIS
I love watching your videos, I was just curious if we take this problem statement to a next level where .. what if a certain number occurs for the same number of time as that the other i.e., if arr[]={1,2,2,3,3} ; , if we go by the above mentioned algorithm, we will just get max_value as 2 and max_occurrence as 2 which will be unfair to 3 which too occurs for the maximum number of times that is 2 .
What can we do to print all the most occurring number as well as their occurrences in such cases ? 😅, I tried but can't come up with an optimal solution .
This is a great question but completely answering it might be too long for what I can cover in a UA-cam comment. :-)
I think we would need to store each "max value" in an array. Whenever we find a max value with occurrences greater than the existing max value, we would wipe out whatever is in the array and this value would become the new and only max value. But if we find a new max value with a "tying / equal" amount of occurrences, we would add it to the array of values instead. And then when we're done checking all the elements in the array we could output whatever is in the "max values array". That would be the general idea.
Another way would be to count the occurrences of "everything" and store the results into an array of structs where each struct stores the value and number of occurrences, and then sort that array of structs by the number of occurrences, and check using the sorted array to see if there are any values that share the maximum number of occurrences. :-)
@@PortfolioCourses oh you actually corrected me there, tysm for the suggestion 😀
@@PortfolioCoursescode dedijiye iska.please.
I was thinking the same question and see I found your comment if you have find the code please share the same to me.
@@adicodes11
I was thinking the same question and see I found your comment if you have find the code please share it to me.🙏🏻🙏🏻
your videos are very helpful thanks a lot!
You're very welcome, I'm glad you're finding them helpful! :-)
can you make a video about Heap Sort
what is the difference between max_value and max__occurenceis??
max_value is the value itself that occurs most frequently, and max_occurrences is the number of times that value occurs
Thank you so much
helpful video❤🔥
How to write this program?
Write a c program to read a sentence from user and then remove all articles from it and display the updated sentence.
Eg.
Input:An apple a day.
Output:apple day.
What do you mean by articles....wouldn't you just make a list of the words to exclude and then check and remove them
@@gerdsfargen6687 in c not python
@yogeshchauhan9401 true..sorry I didn't check..yes lists can't be done in c. I wish I could help.
I can give you some hints: look into strtok, strcmp and set a list of strings that contains all articles. You can set such a list like this: char mylist[NUMBER_OF_ARTICLES][MAX_LENGTH_OF_ARTICLES]
@@Albertinio1994 u mean 2d array
will it work the same if i put the “if (occurences > max_occurences)” inside the inner loop?
Love your videos🙌🏻
Yes that should work the same. And I’m glad you enjoy the videos! :-)