Java data sturcture searching and sorting


Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Please follow the guidelines below:
Submit the homework and lab solutions in the drop box. For a programming question,
submit a .java file (for source code) and a .txt file for program output. If the problem
involves other questions, submit a separate .txt file to answer the question.    
P1 (20 points)
Implement a binary search of an array iteratively using the methodpublic 

static <T extends Comparable<? super T>> booleaninArrayIterativeSorted(T[]
anArray, T anEntry)
P2 (30 points)
Consider an array data of n numerical values in sorted order and a list of numerical target
values (target values are not necessarily sorted). Your goal is to compute the smallest range of
array indices that contains all of the target values. If a target value is smaller than data[0], the
range should start with -1. If a target value is larger than data[n – 1], the range should end with
For example, given the array [ 5 8 10 13 15 20 22 26] and the target values (8, 2, 9, 17), the
range is -1 to 5.
1.   Devise an efficient algorithm that solves this problem and implement it in
public static <T extends Comparable<? super T>>
Interval findInterval(T[] sortedData, List<T> targetValues)

where Interval is a class that provides two public methods getLower() and getUpper() to return
the lower and upper values of an Interval object. Implement the Interval class.

2.   If you have n data values in the array and m target values in the list, what is the Big Oh
performance of your algorithm?  
P3 (20 points)
Write the java code for the method
pubic static <T extends Comparable<? super T>> boolean  isSorted(T[ ] a)
which returns true if the array a is in sorted in ascending order. The code must run in O(n) time.
P4 (30 points)
Consider a revised selection sort algorithm so that on each pass it finds both the largest and
smallest values in the unsorted portion of the array. The sort then moves each of these values
into its correct location by swapping array entries.
1.   Implement the modified selection sort using the method
public static <T extends Comparable<? super T>> void modifiedSelectionSort(T[] a, int n)
2.   How many comparisons are necessary to sort n values?

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.
Open chat
Order through WhatsApp!
You Can Now Place your Order through WhatsApp

Order your essay today and save 30% with the discount code ESSAYHELP2