1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alex_Xolod [135]
3 years ago
10

Given a string, return the character that appears the maximum number of times in the string. The string will contain only ASCII

characters, from the ranges ('a'-z',A-Z,0'-9'), and cas matters. If there is a tie in the maximum number of times a character appears in the string, return the character that appears first in the string.
For example, given the string text abbbaacc, both a and b occur 3 times in text. Since a occurs earlier, a is the answer.
Function Description
Complete the function maximumOccurringCharacter in the editor below. The function must return the character that appears first in the string.
maximumOccurring Character has the following parameter text: the string to be operated upon
Constraints
10 < and equal lenath of text All characters are alphanumeric, in the ranges ('a'-z',A-Z,0-9')
Computers and Technology
1 answer:
g100num [7]3 years ago
6 0

Answer:

The function in Python, is as follows:

def maximumOccurringCharacter(mystring):

kount = [0] * 256

maxKount = -1

chr = ''

for i in mystring:

 kount[ord(i)]+=1;

for i in mystring:

 if maxKount < kount[ord(i)]:

  maxKount = kount[ord(i)]

  chr = i

return chr

Explanation:

This defines the function

def maximumOccurringCharacter(mystring):

This creates a list of 256 characters (the number of ascii characters); the list is then initialized to 0

kount = [0] * 256

This initializes the maximum count to -1

maxKount = -1

This initializes the string with maximum number of occurrence to an empty character

chr = ''

This iterates through the string and gets the occurrence of each character

for i in mystring:

 kount[ord(i)]+=1;

This iterates through the string, compares the occurrence of each string with maxKount and return the character with the highest

<em> for i in mystring: </em>

<em>  if maxKount < kount[ord(i)]: </em>

<em>   maxKount = kount[ord(i)] </em>

<em>   chr = i </em>

<em> return chr</em>

You might be interested in
Plz help meeeeee QUICKLY!!! WORTH 15 POINTS!
Lady bird [3.3K]

Answer:

Im pretty sure Domain name system but dont trust me

Explanation:

8 0
4 years ago
giving Brianlist (to the correct answers)help plesee question is what is keyboard (long paragraph)​plzz don't spam with unnecess
Ira Lisetskai [31]

Answer:

Explanation:

A computer keyboard is an input device that allows a person to enter letters, numbers, and other symbols (these are called characters in a keyboard) into a computer. Using a keyboard to enter lots of data is called typing. A keyboard contains many mechanical switches or push-buttons called "keys".

7 0
3 years ago
1 Let Σ= {Ac,BA,bcb,cd,ab,d,i}. Find the length for the given below strings
Zepler [3.9K]

Answer:

What in the world

Explanation:

4 0
3 years ago
Which of these completes the sentence? People interpret information ___________. Choose one.
evablogger [386]

Explanation:

mannejaondpsbma0jdjdhdj

5 0
3 years ago
Read 2 more answers
Please tell fast plzzzzzz. ​
shepuryov [24]

Answer:

true....................

6 0
3 years ago
Read 2 more answers
Other questions:
  • In your presentation you added a text box to?
    5·1 answer
  • Which Command Prompt commands in Windows is used for listing a computer connections to shared resources
    10·1 answer
  • What does “int” means in php code
    13·1 answer
  • Jason works as an accountant in a department store. He needs to keep a daily record of all the invoices issued by the store. Whi
    13·2 answers
  • In what areas is leslie's underspending hurting her
    10·1 answer
  • Below is a 4-bit down-counter. What is the largest number of the counter if the initial state Q3Q2Q1Q0=0011? (D3 and Q3 are MSB,
    14·1 answer
  • The _____ handles the instructions for your computer to start up before the operating system is loaded.
    11·1 answer
  • What is meant by check digit
    10·1 answer
  • Word can only print documents on one size of paper.<br><br> True or false
    15·1 answer
  • A leading global vendor of computer software, hardware for computer, mobile and gaming systems, and
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!