Create a recursive program


Discuss the below:

Q: Implement a class 'SearchSort' which contains recursive versions of the methods below:

static void selectionSort(Comparable[] list)
static boolean binarySearch(Comparable[] list, Comparable target) // true if target in list

The signatures of the method like the ones above.
The class (SearchSort) must also have the method 'static boolean isSorted(Comparable[] list)' that returns true if (and only if) the enclosed list is sorted (smallest item first).

Another program 'SearchSortMain' shows and tests the different methods.

Enclosed please find an example of names and telephone numbers that can be used for sorting.public class PhoneList
{
//-----------------------------------------------------------------
// Creates an array of Contact objects, sorts them, then prints
// them.
//-----------------------------------------------------------------
public static void main (String[] args)
{
Contact[] friends = new Contact[8];

friends[0] = new Contact ("John", "Smith", "610-555-7384");
friends[1] = new Contact ("Sarah", "Barnes", "215-555-3827");
friends[2] = new Contact ("Mark", "Riley", "733-555-2969");
friends[3] = new Contact ("Laura", "Getz", "663-555-3984");
friends[4] = new Contact ("Larry", "Smith", "464-555-3489");
friends[5] = new Contact ("Frank", "Phelps", "322-555-2284");
friends[6] = new Contact ("Mario", "Guzman", "804-555-9066");
friends[7] = new Contact ("Marsha", "Grant", "243-555-2837");

Sorting.selectionSort(friends);

for (Contact friend : friends)
System.out.println (friend);
}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a recursive program
Reference No:- TGS01931762

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)