# computer science

posted by .

Hey I have three questions with creating these methods, thanks.

Write a Function
You will be given one of the following problems to solve using and writing Java functions.

1.
Given a list of words, return an array which indicates the frequency that each letter occurs. For example, in the list [”apple”, ”bob”], [ ’a’ -> 1, ’b’->2, ’e’->1, ’l’->1, ’o’->, ’p’->2] . The order of the array does not matter and a Frequency class will be provided.

2.
Given a list of words, indicate whether the list constitutes a ”Word Lad- der.” A Word Ladder is a series of words where each succeeding word changes by only one letter. You may not assume that all words will be of the same length, and you may not assume the length of the list.

3.
Given an integer greater than 2, X, return an array populated with all prime numbers up to and including X.

• computer science -

1.
Check with your teacher if the list is supposed to be case sensitive. From the context of the question, it should not be.
In this case, convert all the strings into lowercase and compare using the String.toLowerCase() method before comparison.
The comparison can be done character by character using the String.charAt(i) method.
Use an array of size 26 to store the frequencies. Do not forget to initialize the array (or the Frequency class values).
Read the Java API for more details.
http://java.sun.com/javase/6/docs/api/

• computer science -

2.
First compare the lengths of the successive words using String.length().
If they equal, then compare letter by letter, and count the number of different letters. If the difference equals 1, continue the "ladder".
You may have to convert all letters to lowercase before the comparison.

3. There are plenty of algorithms for finding prime numbers. One of them is to test the divisibility by primes. You will have to create a list of primes, starting with 2, which is assumed to be a prime. Test all odd numbers starting from 3. Whenever you find that the number does not divide by the numbers on your prime list, you have found a prime, and add it to your prime list.

For example 3 does not divide by 2, so add 3 to the prime list. 5 does not divide by 2 and 3, add it to the prime list. Likewise, 7 is added to the prime list. 9 divides by 3, so skip it.
11 does not divide by 2,3... so it is a prime.

You do not have to test all the primes on the prime list. If the square of the prime on the prime list exceeds the number X to be tested, X can be declared a prime. For example, for 11, it is not divisible by 2,3, but 5²>11, so 11 can be declared a prime.

It may sound complicated, if you post your pseudocode or the Java code, you can get further help.

## Similar Questions

1. ### math

can some one please help me with the following questions as i don't understand them please (a) write down the derivative of each of the functions f(x)=E7x and g(x)=cos(2x) using the product rule differentiate the function k(x)=E7xcos(2x) …
2. ### Creative Writing

this is one of my assignments that i'm stuck on: write down your three favorite flavors of ice cream and three different toppings. Classify the information by pairing each flavor of ice cream with each topping. List some of the words …
3. ### computer science

Hey I have three questions with creating these methods can any of you guys write an example code for this?
4. ### Computer science

Write a function in Python: Given a list of words, indicate whetehr the list constitutes a "Word Ladder." A Word Ladder is a series of words where each succesding word changes by only one letter. You may assume that all words will …
5. ### Computer Science JAVA FUNCTIONS

Write a Function You will be given one of the following problems to solve using and writing Python functions. Given a list of words, return an array which indicates the frequency that each letter occurs. For example, in the list [”apple”, …
6. ### C++ programming computer

I'm having some trouble trying to program these problems and putting them into the main function. Please help me by giving some advice or website that offer good information for me. The questions are below here: 1. Write a function …
7. ### COMPUTER SCIENCE JAVA

Assignment problems: Write Java programs for each of the following. 1. Students in a university class are being organized into groups of three for an upcoming research project. To model this situation: a. Write a Student class that …
8. ### COMPUTER SCIENCE JAVA

Assignment problems: Write Java programs for each of the following. 1. Students in a university class are being organized into groups of three for an upcoming research project. To model this situation: a. Write a Student class that …
9. ### Trigonometry

Alrighty I have to find two real world sinusoidal functions. I found: 1. A piston in an engine moves up and down in a cylinder. The height, h centimeters, of the piston a t seconds is given by the function: h= 120 sin(πt) + 200. …
10. ### computer, science, java, software

Write a Java program to declare and store numbers from 1 to 10 in a single dimensional array and display the output in the following format. 1 2 3 4 5 6 7 8 9 10

More Similar Questions