Your Perfect Assignment is Just a Click Away
We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Analysis of Algorithms & Searching and Sorting

Analysis of Algorithms & Searching and Sorting

Analysis of Algorithms & Searching and Sorting
profile
modiishan21

TheShellsortisavariationofthebubblesort.docx
Home>Computer Science homework help>Analysis of Algorithms & Searching and Sorting
1. The Shell sort is a variation of the bubble sort. Instead of comparing adjacent values, the Shell sort adapts a concept from the binary search to determine a “gap” across which values are compared before any swap takes place. In the first pass, the gap is half the size of the array. For each subsequent pass, the gap size is cut in half. For the final pass(es), the gap size is 1, so it would be the same as a bubble sort. The passes continue until no swaps occur.

Below is the same set of values as per the bubble sort example in Chapter 18 (p. 681), showing the first pass of the Shell sort:

The pseudo-code for the Shell sort is as follows:

Create a class called ShellArray. It should create and populate an array of random integers based on a size supplied to the constructor. Implement the Shell sort as a method of this class. Create a driver class to instantiate and sort several different arrays of different sizes.

Hint: Implement a toString method for the ShellArray class, so it is easy to output the results of each swap to demonstrate that your algorithm is working correctly.

2. Modify the sorts listed in Chapter 18 (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. Execute the sort algorithms against the same list, recording information for the total number of comparisons and total execution time for each algorithm. Try several different lists, including at least one that is already in sorted order.

Note that the original code for all the sorts is contained in the Chapter 18 source code folder. It is recommend that you use a spreadsheet to present the test cases you have prepared, along with the comparisons and execution time.

Hint: Remember that arrays are passed by reference in Java. Use Arrays.copyOf() or a similar method to test each sort method on the exact same data content in separate arrays.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Topnotch Essay only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Topnotch Essay are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Topnotch Essay is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Topnotch Essay, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.