Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java code 3.2 Add a method called median() to the ArrayIns class in the insertSort.java program (Listing 3.3). This method should return the median value

java code image text in transcribed
image text in transcribed
3.2 Add a method called median() to the ArrayIns class in the insertSort.java program (Listing 3.3). This method should return the median value in the array. (Recall that in a group of numbers half are larger than the median and half are smaller.) 3.3 To the insertSort.java program (Listing 3.3), add a method called noDups() that removes duplicates from a previously sorted array without disrupting the order. You can simply use main() to insert the data in sorted order. One can imagine schemes in which all the items from the place where a duplicate was discovered to the end of the array would be shifted down (left) one space every time a duplicate was discovered, but this would lead to slow O(N^2) time, at least when there were a lot of duplicates. In your algorithm, make sure no item is moved (left) more than once, no matter how many duplicates there are. This will give you an algorithm with O(N) time. You may not use a second array to remove the duplicates. Input: arr[] = {1, 2, 2,3,4,4,4,5,5) Output: arr[] = {1,2,3,4,5) new size = 5 Figure 3.2.1: Bubble sort algorithm. BubbleSort(numbers, numbersSize) { for (i = 0; i numbers [j+1]) { temp = numbers [j] numbers [j] = numbers [j + 1] numbers [j + 1] = temp } } 2 3 Feedback

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago