Question
Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median
Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish.
Step 1. Create the pseudocode that you will use to write the program. Place the algorithm in a Word document.
Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1. Generate 11 random integer numbers between 1 and 100, and place each random number in a different element of a single-dimension array starting with the first number generated. 2. Display the array's contents in the order the numbers are initially inserted. This is called an unsorted list. An example is below.
3. Using the bubble sort, now sort the array from smallest integer to the largest. The bubble sort must be in its own method; it cannot be in the main method. Here is the code for the bubble sort method. Use this code, and not some code you find online. Bubble Sort Code: public static void bubbleSort(int[] list) { int temp; for (int i = list.length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (list[j] > list[j + 1]) { temp = list[j]; list[j] = list[j + 1]; list[j + 1] = temp; } } } }
4. Display the array's contents after the bubble sort is completed. An example is below. 5. Locate the median of the 11 numbers. The formula for finding the position of the median in a list of sorted numbers is: ([the number of data points] + 1) 2. In this case, 11 is the number of data points. You must use implement this formula to locate the cell in the array that contains the median and not just display the item at location 6 of the array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started