Question: JAVA Program: Write a Java Program that implements these methods (see below). Requirements: 1. Write/ Implements Methods 1.1 Generic Binary Search public static int binarySearch(E

JAVA Program: Write a Java Program that implements these methods (see below).

Requirements:

1. Write/ Implements Methods

1.1 Generic Binary Search

public static > int binarySearch(E [] list, E key)

1.2 Shuffle ArrayList *Hint: Make use of random numbers

public static void shuffle(ArrayList list)

1.3 Sort ArrayList

public static extends Comparable> void sort(ArrayList list)

2. Write main method and call the methods with various data types.

3. Create a main method that creates data (hard code arrays and ArrayLists) and calls each method three different ways (meaning different types of data) and prints out what the method returns.

For example in 1.1 you might call it with an Integer array and a Character array like this:

Integer[] ints = {1,2,3,4,5,6,18,30};

System.out.print(binarySearch(ints, 18));

// returns 6, print it out using println BinarySearch for 18 returns position 6

Character[] chars = {a, d, m};

System.out.print(binarySearch(chars, m));

// returns 6, print it out using println BinarySearch for m returns position 2

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!