1)

Let’s say our main method looks like this:

public static void main(String[] args){ int numbers[] = {0, 6, 12, 33, 53, 56, 56, 903}; int foundIndex = mysteryMethod(numbers, 6); }

Choose the correct process for each Step below, for analyzing the Search method.

Step 1:                             [ Select ]                       [“Our mid variable equals 4”, “Our mid variable equals 3”, “Our mid variable equals 5”]

Step 2:                             [ Select ]                       [“a[mid] = 53”, “a[mid] = 33”, “a[mid] = 12”]

Step 3:                             [ Select ]                       [“Since our key of 6 is smaller than a[mid], we now check the bottom half”, “Since our key of 6 is larger than a[mid], we now check the upper half”]

Step 4:                             [ Select ]                       [“Our new high variable now equals 2”, “Our new high variable now equals 1”, “Our new low variable now equals 3”]

Step 5:                             [ Select ]                       [“Our new mid variable now equals 2”, “Our new mid variable now equals 1”]

Step 6:                             [ Select ]                       [“a[mid] now equals 0”, “a[mid] now equals 6”, “a[mid] now equals 12”]

Step 7:                             [ Select ]                       [“Since our key is less than a[mid], we now check upper remaining half”, “Since our key is higher than a[mid], we now check lower remaining half”, “a[mid] == our key, so now we return mid (which is 1)”, “We didn’t find our key, so return -1”]

Step 8:                             [ Select ]                       [“When we check the upper half, we find our key, and so return the new mid value”, “There is no Step 8. We finished in the last step.”, “After checking, we do not find 6, and so return -1.”]

2)

Let’s say we call our mysteryMethod() using the following:

public static void main(String[] args){ int numbers[] = {5,3,2,8}; mysteryMethod(numbers); }

For each iteration in our method, choose the correct order of array elements. The first couple of steps are given to you. You will also need to keep track of the values of k and i in the nested for loop, for each step.

Note: Please enter integers. Don’t use words to represent numbers. Whole numbers only!

 value of k and i index 0 index 1 index 2 index 3 5 3 2 8 1 and 0 3 5 2 8 1 and 1 1 and 2 2 and 0 2 and 1 ignore row

Array is completely sorted by this point, so stopping early (even though it would continue running until k became 3 and the nested for loop finished).

3)

Let’s say we call our mysteryMethod() using the following:

public static void main(String[] args){ int numbers[] = {5, 3, 2, 8, 7, 9, 6}; mysteryMethod(numbers); }

For each iteration in our method, record the correct order of the sorted array elements after that current iteration (value of i). The first few steps are given to you as an example.

It will also help you to keep track of the values of i, currentMin, currentMinIndex, and j for each step

Note: Please enter integers and separate using a space only. Don’t use words to represent numbers. Whole numbers only!

 int i Values of Array 5 3 2 8 7 9 6 0 2 3 5 8 7 9 6 1 2 3 5 8 7 9 6 2 3 4 5

We are now done sorting! Please explain how you sorted this as well!