Question: This is a review for how to do programming but how do they all work together in java I am confused For each of the

This is a review for how to do programming but how do they all work together in java I am confused

For each of the numbered tasks below, please read these instructions carefully and do the following:

Demonstrate that your code works by calling each method and printing out the results.

All of your code should be in one file.

Your main should call these methods with the appropriate parameters. None of your methods should input values from the keyboard. Only main should do input.

To facilitate testing, you should ask the user for target values to search for with the binary and linear search methods.

Youll need to think about how to solve these problems. The worst approach is to start writing code. Make some sample arrays and write an algorithm in pseudocode to solve this problem. Practice your algorithm on paper by hand on a few examples.

Upload your java code and a file containing the output of running your program to show that it works. You can use the Windows snipping too or just copy and paste the output into a text file.

Tasks

Write a method called createRandomIntArray that will create and return the address of an array (that you create) of random integers between zero and one hundred of size n, where n is passed to your method. This method will let the caller get arrays of different sizes.

Write a method called smallest that will return the smallest value in an integer array.

Write a method called indexOfSmallest that will return the index of the smallest value in an integer array.

Write a method called equalIntArrays that will return true if two arrays of integers that are passes to it are equal.

Write a method called equalStringArrays that will return true if two arrays of Strings that are passes to it are equal.

Write a method called linearSearch that performs a linear search on an integer array: searches starting at index 0, then 1, 2, 3. It should return the index of the array that contains the target or a -1 if it is not found in the array

Write a method called count that determines the number of times a target value appears in an array. For example, if your array is [2, 3, 3, 3, 4, 6, 7, 8, 8, 9], the value 8 appears twice and the number 4 appears once. You should know that the method has two parameters and one return value.

Write a method called mode that determines which value appears most frequently in the array. In the array [2, 3, 3, 3, 4, 6, 7, 8, 8, 9], the number 3 appears most frequently.

Write a method called antiMode that determines which value appears least frequently in the array. In the example above, any of the numbers 2,4,6,7,9 would be correct results

Write a method called binarySearch that performs a binary search. A binary search searches starting at the middle of the (sorted) array. If it is not found, it searches in the bottom half or top half of the array depending on whether the target is less than or greater than the value in the middle of the array. It does this repeatedly until it finds the value or determines that the value is not in the array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!