Question: 1.)Examine the code above. What method do you think it is performing? Before answering this question with your partner, discuss with the whole group. a

1.)Examine the code above. What method do you think it is performing?

Before answering this question with your partner, discuss with the whole group.

a Binary Search
b Bubble Sort
c Merge Sort
d

Selection Sort

2.)

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
0 5 3 2 8 7 9 6
1 2 3 5 8 7 9 6
2 2 3 5 8 7 9 6
3
4
5

We are now done sorting!

3.)

Inside of the method m, what is the value of each of the following. Think about what will be displayed when we get to the print statements.

num

Which Answer: 6 3 2 Not in this scope 5 1 7

nums[0]

Which Answer: 6 3 2 Not in this scope 5 1 7

nums[1]

Which Answer: 6 3 2 Not in this scope 5 1 7

a

Which Answer: 6 3 2 Not in this scope 5 1 7

4.)

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."]

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!