A recursive method counts and returns how many even numbers are in an array of positive integers.

public static int countEven(int[] nums, int index)

For example, if nums = {2,5,5,6,8} then a call to:

countEven(nums, 0) will return 3.

Implement this method! Test it in your IDE to check it works as expected.

m18h2

Consider the following recursive method.

public void recursionEx(int x){

if(x != 0){

System.out.println(x);

recursionEx(x - 1);

System.out.println(x);

}

}

Copy and complete the following table to show the output when the method is called by:

recursionEx(3);

parameter passed to method output
3  
   
   
   
   
   
   

The real estate business keeps the data of all past owners in a file for future reference.

This file is sorted by owner name. When needed, this file is read into a LinkedList called contacts, which has been instantiated as follows.

private ArrayList contacts = new ArrayList();

Construct a recursive binary search method given as:

public Owner binSearch(String name, int low, int high)

where name is the search term

.

You may assume that contacts is accessible to binSearch and that it has been filled with many objects.

You may use the following standard ArrayList method.

.get(int index)

This returns the object located in the ArrayList at index.