Description: Write a program to find the maximum occurring character in an input string.
Input String: “ipupilis”
Character ‘i’ is the maximum occurring character.
1) Create an array ‘count’ and initialize each element to 0. The array ‘count’ stores the number of times each character occurs. So if character ‘k’ occurs 5 times, count[‘k’] is equal to 5.
2)Scan the string from left to right incrementing count corresponding to the character being scanned.
Repeat count[S[i]]=count[S[i]] + 1
for all values of ‘i’.
3)Initialize ‘max’ as the count of the first element of the string and ‘x’ as the first character.
Scan through the remaining string S using index ‘i’ comparing the value of the corresponding value of ‘count’ with ‘max’ and updating:
if(count[S[i]] > max)
4)’x’ stores the maximum occurring character in the string.
/*The following function returns the maximum occuring character.*/
char maxoccuring(char String)