Reference no: EM131561248
Sorting Comparisons Preface
For this lab, you will implement the five sorting algorithms we discussed (selection, bubble, insertion, merge, quick), and compare their runtime performance.
Requirements
- Create a class called SortingComparison.
- In that class, create five static methods, one for each algorithm that sorts an array of a generic type, using this header format:
? public static <E extends Comparable<? super E>> E[] algName(E[] arrayToSort)
? Each algorithm takes in an array of items of a generic type E (which may or may not be sorted), and returns an array that has the items sorted from smallest to largest.
- You may, and should, create private helper methods for some sorting algorithms.
- Write additional functionality that does the following.
? Creates 1,000 arrays that each hold 100,000 items that are randomly generated.
? Passes each of the 1,000 arrays to each sorting algorithm method.
? Measures how long it takes each call to a sorting algorithm method to complete.
? Calculates the average time for each sorting method to sort the 1,000 arrays.
? Prints the average time for each sorting method to the console.
Hints
- Use System.nanoTime() to calculate how long it takes a sorting method to complete.
- For example:
? Integer[] arrayToSort; // build a random array to sort.
? long beginTime = System.nanoTime();
? insertionSort(arrayToSort);
? long endTime = System.nanoTime();
? long elapsedTime = endTime - beginTime;
? // elapsedTime contains how long it took insertionSort to complete.
- You can search for, find, copy, and adapt existing sorting implementations.
Discussion of freedom with fences
: 1. Reflect upon Robert Stephens' discussion of "Freedom with Fences" from Chapter 1 of CIO Best Practices.
|
What is the change in the forecasted operating loss
: What is the change in the forecasted operating loss for the upcoming year if the western territory is dropped
|
Describe two real-life scenarios you have experienced
: Do you agree with the behaviorist view that learning can be described simply in terms of stimulus-response relationships?
|
How global market would affect business strategy of riordan
: Explain how the global market would affect the business strategy of Riordan. Explain why you chose these competitive strategies?
|
Implement the sorting algorithms
: You will implement the five sorting algorithms we discussed (selection, bubble, insertion, merge, quick), and compare their runtime performance
|
Apple biggest successes and failures
: What were some of Apple's biggest successes and failures? Describe why.
|
Describe how memory development and learning affect
: Apply basic research methods in psychology to your initial statements on these issues by researching at least one peer-reviewed article per memory type.
|
Identify the organizations core competencies
: Identify the organization's core competencies. Determine if the organization lives up to its own mission, vision, and values.
|
What is its total asset turnover
: A company has sales of $500,000, cost of goods sold of $100,000, operating expenses of $100,000, average inventory of $8,000, what is its total asset turnover
|