Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

Requirements: Compare the efficiency of Selection Sort and Insertion Sort.

Approach: Evaluate the following Selection Sort and Insertion Sort codes in at least one case (best, worst, or average) and count the number of type of operations performed (assignments, comparisons, and overall, separately). For counting them, you need to add in the right place specific statements to increment the counters for assignments and/or comparisons, wherever needed.

Selection Sort code:

// Method: selectionSort
// Author: instructorX
// Date: dd/mm/yyyy
// Purpose: A method that sorts an array using a selection sort

public static void selectionSort(Comparable[] array)
{
int i;
for (i = 0; i < array.length; i++)
{
int minIndex = i;
for (int j = i + 1; j < array.length; j++)
if (array[j].compareTo(array[minIndex]) < 0)
minIndex = j;
swap(array, minIndex, i);
}
}

Insertion Sort code:

// Method: insertionSort
// Author: instructorX
// Date: dd/mm/yyyy
// Purpose: A method that sorts an array using an insertion sort

public static void insertionSort(Comparable[] array)
{
for (int i = 1; i < array.length; i++)
{
Comparable temp = array[i];
int j = i - 1;
while (j >= 0 && temp.compareTo(array[j]) < 0)
{
array[j + 1] = array[j];
j--;
}
array[j +1 ] = temp;
}
}

Draw charts to show how the running time (estimated in numbers of assignments A(n), comparisons C(n), and overall time T(n)=A(n) + C(n)) grows as the size of the input data n is growing. To draw the charts, vary the input size (n) between 100 and 1000, with an increment of maximum 100. For each size, generate the appropriate input sequence (best, worst, or average) for the specific sorting method (be aware: best/worst cases are not necessary the same for the two methods), run it, and store the values (A(n), C(n), T(n)). The easiest way to draw them is by using Microsoft Excel Worksheet.

In case the average case is your choice, you have to repeat the measurements m times (m=5 should suffice) and report their average. Moreover, for the average case, make sure you always use the same input sequence for both sorting methods for a fair comparison.

For the analyzed case(s), generate charts which compare the two methods; use different charts for the number of comparisons, number of assignments and total number of operations. Name your charts and curves on each chart appropriately (that is, specify what the chart/curve represents).

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92027707
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Describe the definition of ransomware and what is wannacry

Describe the definition of ransomware. And what is wannacry threat?

Question suppose a binary tree t has 10 nodes which are

Question : Suppose a binary tree T has 10 nodes which are labeled 0,1,2,...,9. We ran the inorder and postorder traversals on the tree and the nodes were processed in the following order: inorder traversal: 0,3,1,2,9,4,6 ...

Assume that the pizza market consists of two firms conans

Assume that the pizza market consists of two firms, Conan's and Pizza Hut. The price of a Conan pizza is denoted by Pc and the price of a Pizza Hut Pizza is P h.  Both sellers have a marginal cost of $5 for another pizza ...

Question suppose you are stranded on a desert island on

Question : Suppose you are stranded on a desert island on which queues are plentiful, but you need a stack. How can you implement a stack using two queues? What is the big-Oh running time of the stack operations?

Question using a web browser perform some research on a

Question: Using a Web browser, perform some research on a newer malware variant that has been reported by a major malware containment vendor. Using a search engine, go to the vendor's Web site; this could be Symantec, Mc ...

Assume that the hypothetical economy of mo has 8 workers in

Assume that the hypothetical economy of Mo has 8 workers in year 1, each working 1,500 hours per year (50 weeks at 30 hours per week). The total input of labor is 12,000 hours. Productivity (average real output per hour ...

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

Red bull is the most popular energy drink in sales in the

Red Bull is the most popular energy drink in sales in the United States. Red Bull GmbH (the parent company) has observed that daily sales are normally distributed with an average of 6,329,903 drinks sold with a standard ...

A survey is taken of people in the class of favorite flavor

A survey is taken of people in the class of favorite flavor of ice cream among a forced choice of chocolate, vanilla, or strawberry. 70% prefer chocolate, 20% prefer vanilla, and 10% prefer strawberry. a) What is the ent ...

What is the various security architectures which provides

What is the various security architectures. Which provides the best balance between simplicity and security? Justify your answer.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As