Question: Complete Chapter 8, Programming Activity 2: Searching and Sorting Arrays. Make sure you study the Programming Activity 8-2 Guidance document Programming Activity 8-2 Guidance =================================

Complete Chapter 8, Programming Activity 2: Searching and Sorting Arrays.

Make sure you study the Programming Activity 8-2 Guidance document

Programming Activity 8-2 Guidance ================================= This assignment gives you practice with searching and sorting a single dimensional array of int values. The name of the array you will be using is arr. Here is the framework statement that defines arr: private static int [] arr; Here is the framework statement that creates arr: arr = new int[SIZE]; Note that arr is an array of int items. Part 1 ------ The framework comments say that the array you are to search has random values. You CANNOT assume that this array is in sorted order. You must look at each value in the array and compare it to the value of the input parameter named "key". If you find it, immediately return the array index where you found it. Since you will return from inside the loop if you get a hit, the code following the loop is only executed if you did not find it. At this point, your code should simply return -1. Part 2 ------ This week's outline contains the following bubble sort pseudocode: for (i = 0; i  array[j + 1]) // Two consecutive elements are in the wrong order { swap them } } } To swap 2 items, you must use of a temporary variable. Assign the first item to the temporary variable. Assign the second item to the first item. Finally, assign the temporary variable to the second item. Here is a swapping example from this week's outline: Example (swapping elements 7 and 8: int temp = array[7]; array[7] = array[8]; array[8] = temp; 

Complete Chapter 8, Programming Activity 2: Searching and Sorting Arrays. Make sureyou study the Programming Activity 8-2 Guidance document Programming Activity 8-2 Guidance================================= This assignment gives you practice with searching and sorting a single

Sequential Search input: Choose your activity Sequential Search Bubble Sort 110 111 63 138 159 100 102 154 89 147 87 33 65 57 108 En Input 2 Enter an integer value between 20 and 160 to search sequentially 33 OK Cancel

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!