Question

1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array...

1.) Generate an array of 10 random numbers between 1 - 100

2.) Copy the array to a temp array

3.) Call each of the methods to sort (bubble, selection, insertion, quick, merge), passing it the array

4.) In-between the calls, you are going to refresh the array to the original numbers.

5.) Inside of each sorting method, you are going to obtain the nanoseconds time, before and after the method Subtract the before time from the after time to obtain total time in nanoseconds

6.) Display the amount of time that the sort took

7.) Tell me which sort was fastest.

Homework Answers

Answer #1

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int i, arr=9; //taking the size of the arrey
int randArray[arr];

for(i=0;i<arr;i++)
randArray[i]=rand()%100+1; //TO Generate number between 1 to 100
  
printf("\n Random number of the array:\n");
  
   for(i=0;i<arr;i++)
{
printf("\nElement number %d : %d",i+1,randArray[i]);
}
  
return 0;

//output photo
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In JAVA Find the code for sorts in your language some where online. You will copy...
In JAVA Find the code for sorts in your language some where online. You will copy code from the internet (with citation!) and modify it to test. Make a random array of integers, then perform each search on them. LINEAR SEARCH Write a linear search method to find a number in the list. Call this before each of your sort methods. Include a comment explaining how Linear Search works, when to use it, when you cannot. BINARY SEARCH Write a...
Do a theta analysis and count the number of computations it performed in each function/method of...
Do a theta analysis and count the number of computations it performed in each function/method of the following code: import java.io.*; import java.util.Scanner; class sort { int a[]; int n; long endTime ; long totalTime; long startTime; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public sort(int nn) // Constructor { a = new int[nn]; n = nn; endTime= 0; totalTime =0; startTime =0; } public static void main(String args[]) throws IOException { System.out.print("\nEnter number of students: "); int nn =...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...