Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to measure the average performance of sorting algorithms with different sizes and numbers(with arrayList ) and compare with a graph? I have these methods:

How to measure the average performance of sorting algorithms with different sizes and numbers(with arrayList) and compare with a graph?

I have these methods:

//This one receives one size(n) parameter

public static ArrayList RandomArray(int n){ ArrayList randomArray = new ArrayList(n); Random rand = new Random(); //--- random number rand.setSeed(System.currentTimeMillis()); for(int i = 0; i < n; i++ ) { //loop for creating random numbers until n size randomArray.add(i, Math.abs(rand.nextInt() % 256)); } return randomArray; }

//I have this one to show the Array

public static void ShowArray(ArrayList array) { for(int arrayItem : array) { System.out.println(arrayItem); }

}

//and this ones on my main

ArrayList arrayShow = RandomArray(4); // this one to create an ArrayList and using the method RandomArray with the n Size. System.out.println(arrayShow); ArrayList sortArrayA = new Sorting().SortX(arrayShow).; ArrayList sortArrayB = new Sorting().SortY(arrayShow); ArrayList sortArrayC = new Sorting().SortZ(arrayShow);

Now I have 3 sorting methods in a different file, how can I measure the performance of each algorithm, and compare? Where should I set a timer when I call each sort method, and should I create a loop to run like 5000 times so that I can compare?

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

Step: 3

blur-text-image

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions