CS480L MID Q8 String Frequency

Last update: 11/9/2016 10:58:00 AM

By Fatih KABAKCI

The following Java program has been published to figure out how many times each of letters appears in a given string by calculating frequency of them. The program basically uses a TreeMap which is one of the JCF (Java Collection Framework) objects to store characters to avoid counting them more than once. The TreeMap object alphaMap is used to store characters and their frequency values as key value pairs. First, the program checks if each character that is analyzed in string is counted before by looking up in alphaMap. If it finds out that related character have already used before, then it skips and passes on another character to count it. Otherwise, it counts a new character, then it saves it in alphaMap. Finally, helping a Iterator object, all data is printed in console. The method count() returns the actual frequency value of a character in the string.

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine.
Java,C,
C++,C#

Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies.
J2EE,Servlet,
JSP,JSF,
ASP

Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones.
J2ME

A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system.
Linux,Windows