Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 3: Functions or classes are ok. Create an array that holds 1000 random floats between 1-1000. Implement Merge Sort to sort the values in

Task 3:

Functions or classes are ok.

Create an array that holds 1000 random floats between 1-1000.

Implement Merge Sort to sort the values in ascending order. Least Greatest

Measure the time it takes to execute the sort in milliseconds or even nanoseconds.

Please run the sort 3 times.

  • Attach Photos of Source Code and Output-----

  • ---------------------------------------------------------------------------Here is the code Implement Selection Sort to sort the values in ascending order. Least Greatest

  • #include  #include #include using namespace std; void swap(float *xp, float *yp) { float temp = *xp; *xp = *yp; *yp = temp; } void SortingSelection(float arr[], int n) { //clock to check time int i, j, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n-1; i++) { // Find the minimum element in unsorted array min_idx = i; for (j = i+1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; // Swap the found minimum element with the first element swap(&arr[min_idx], &arr[i]); } } int main() { // your code goes here int size = 1000; float arr[size]; int i=0; int high = 1000; srand(time(0)); for(i=0;i 

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

3030871002, 978-3030871000

More Books

Students also viewed these Databases questions

Question

2. What are your challenges in the creative process?

Answered: 1 week ago