程序代写代做 Java Hive algorithm CS526 Homework Assignment 5

CS526 Homework Assignment 5
Due: 3/3
This assignment is a practice of designing recursive algorithms.
Write a java program named Hw5.java, which includes the following two recursive methods. Both methods are very small in terms of their size. So, writing codes itself is not difficult. What is important is to come up with recursive ways of implementing the given requirements. So, this assignment is more about design of recursive programs rather than implementation of recursive programs.
The first recursive method calculates a difference between two bit patterns. There are different ways of determining a difference between two bit patterns. The method you will use for this assignment is illustrated below:
Given the following two bit patterns:
Bit pattern 1: 0 0 1 0 1 1 0 1
Bit pattern 2: 0 1 1 1 1 0 0 1
The difference between the two bit patterns is 3, which is the number of positions where bits from two patterns are different (colored red in the above example). We assume that the lengths of two bit patterns are identical.
As another example, consider the following two bit patterns:
Bit pattern 3: 1 0 1 0 0 1 1 1 0 0 1 Bit pattern 4: 0 0 0 0 1 1 0 0 1 1 1
The difference between the two bit patterns is 7. The signature of the method must be:
public static int recursiveDifference(/* you decide input argument */)
This method calculates and returns the difference between two bit patterns. Note that you must decide the input arguments to the method and remember that this method must be a recursive method.
In your program, a bit pattern must be implemented as an array of characters. For example, the bit patterns 1 and 2 above may be declared and initialized as follows:
char[] bitPattern1 = {‘0’, ‘0’, ‘1’, ‘0’, ‘1’, ‘1’, ‘0’, ‘1’};
char[] bitPattern2 = {‘0’, ‘1’, ‘1’, ‘1’, ‘1’, ‘0’, ‘0’, ‘1’};

The second method calculates the average of numbers in the given array of double numbers recursively. The signature of the method must be:
public static double recursiveAverage(/* you decide input arguments */)
This method calculates the average of numbers in a given array. Note that you must decide the input arguments to the method and remember that this method must be a recursive method.
In your program, the numbers in an array must be of double type and the following is an example of declaring and initializing two arrays:
double[] numbers1 = {15, 3, 12, 27, 48};
double[] numbers2 = {10, 31, 68, 72, 56, 90, 82};
An incomplete code of Hw5.java is posted on Blackboard. It includes a main method that can be used to test your recursive methods. If you complete the program and execute it, your output must be:
Bit pattern 1: [0, 0, 1, 0, 1, 1, 0, 1]
Bit pattern 2: [0, 1, 1, 1, 1, 0, 0, 1]
Difference between the two bit patterns is: 3
Bit pattern 3: [1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1]
Bit pattern 4: [0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1]
Difference between the two bit patterns is: 7
Number array 1: [15.0, 3.0, 12.0, 27.0, 48.0]
Number array 2: [10.0, 31.0, 68.0, 72.0, 56.0, 90.0, 82.0]
Average of numbers in number array 1 is: 21.0
Average of numbers in number array 2 is: 58.42857142857143
Documentation
No separate documentation is needed. However, you must include sufficient inline comments within your program.
Deliverables
You need to submit the following files:
 Hw5.java
 All other necessary files to compile and run your program, if any
Combine all files that are necessary to compile and run your programs into a single archive file. Name the archive file LastName_FirstName_hw5.EXT, where EXT is an appropriate file extension, such as zip or rar. Then, upload it to Blackboard.
Grading
 Recursive difference method: Will be tested with two sets of test input and up to 6 points will be deducted if your output is wrong

 Recursive average method: Will be tested with two number arrays and up to 6 points will be deducted if your output is wrong.
Up to 4 points will be deducted if there are not sufficient comments.